TRAVIS_OS_NAME=osx <<<<<< ENV .swift-version .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata Example/main.swift LICENSE Package.swift Sources/AnError.swift Sources/BCHUtil.swift Sources/Info.plist Sources/QR8bitByte.swift Sources/QRBitBuffer.swift Sources/QRCode.swift Sources/QRCodeModel.swift Sources/QRCodeType.swift Sources/QRErrorCorrectLevel.swift Sources/QRMaskPattern.swift Sources/QRMath.swift Sources/QRMode.swift Sources/QRPatternLocator.swift Sources/QRPolynomial.swift Sources/QRRSBlock.swift Sources/swift_qrcodejs.h Tests/LinuxMain.swift Tests/swift_qrcodejsTests/swift_qrcodejsTests.swift jazzy.sh swift_qrcodejs.podspec swift_qrcodejs.xcodeproj/project.pbxproj swift_qrcodejs.xcodeproj/project.xcworkspace/contents.xcworkspacedata swift_qrcodejs.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist swift_qrcodejs.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings swift_qrcodejs.xcodeproj/swift_qrcodejsTests_Info.plist swift_qrcodejs.xcodeproj/xcshareddata/xcschemes/swift_qrcodejs-iOS.xcscheme swift_qrcodejs.xcodeproj/xcshareddata/xcschemes/swift_qrcodejs-macOS.xcscheme swift_qrcodejs.xcodeproj/xcshareddata/xcschemes/swift_qrcodejs-tvOS.xcscheme swift_qrcodejs.xcodeproj/xcshareddata/xcschemes/swift_qrcodejs-watchOS.xcscheme <<<<<< network # path=./swift_qrcodejsTests-macOS.xctest.coverage.txt 1| |/* 2| | Copyright (c) 2017-2019 ApolloZhu 3| | 4| | Permission is hereby granted, free of charge, to any person obtaining a copy 5| | of this software and associated documentation files (the "Software"), to deal 6| | in the Software without restriction, including without limitation the rights 7| | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8| | copies of the Software, and to permit persons to whom the Software is 9| | furnished to do so, subject to the following conditions: 10| | 11| | The above copyright notice and this permission notice shall be included in all 12| | copies or substantial portions of the Software. 13| | 14| | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15| | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16| | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17| | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18| | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19| | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20| | SOFTWARE. 21| | */ 22| | 23| |import XCTest 24| |@testable import swift_qrcodejs 25| | 26| 6|private func expect(_ qrCode: QRCode?, withFill fill: String, andPatch patch: String, toMatch expected: String) { 27| 6| XCTAssertNotNil(qrCode) 28| 6| let generated = qrCode!.toString(filledWith: fill, patchedWith: patch) 29| 6| XCTAssertEqual(generated, expected) 30| 6|} 31| | 32| |private extension UnicodeScalar { 33| | static let values = Array([0...0xD7FF, 0xE000...0x10FFFF].joined()) 34| 290k| static func randomElement(ignoredParameter: Int = 0) -> String { 35| 290k| return "\(UnicodeScalar(values.randomElement()!)!)" 36| 290k| } 37| |} 38| | 39| 168|private func randomStringOfUTF8Length(_ length: Int) -> String { 40| 168| var str = "" 41| 290k| while str.utf8.count < length { 42| 290k| str += UnicodeScalar.randomElement() 43| 290k| if str.utf8.count > length { 44| 256k| str = String(str.dropLast()) 45| 290k| } 46| 290k| } 47| 168| return str 48| 168|} 49| | 50| |class swift_qrcodejsTests: XCTestCase { 51| 1| func testSimple() { 52| 1| expect(QRCode("https://gist.github.com/agentgt/1700331"), 53| 1| withFill: "##", andPatch: " ", 54| 1| toMatch: """ 55| 1| 56| 1| ############## ###### ## ###### #### ############## 57| 1| ## ## ## ######## #### ## ## ## ## 58| 1| ## ###### ## #### ## #### ## #### #### #### ## ###### ## 59| 1| ## ###### ## ## ###### #### #### ## ## ## ###### ## 60| 1| ## ###### ## ## ######## ## ## ## ## ###### ## 61| 1| ## ## ## ## ###### ## ## ## ## ## ## 62| 1| ############## ## ## ## ## ## ## ## ## ## ## ## ############## 63| 1| ## ## ## ###### ###### 64| 1| #### ######## ## ######## ## ## ## ## ## 65| 1| #### ## ## ## #### ###### ## ## ###### 66| 1| ## ## ######## ## ## ## #### ###### ###### 67| 1| ######## ## ## ## ## ## ## ## ## ###### ## ## 68| 1| ## #### ## ###### ######## ######## #### 69| 1| #### ## ############ #### ## ## ###### ## #### 70| 1| #### #### ## ## ## ## #### #### ## ## ## ## #### 71| 1| ## ## #### #### ## #### #### ######## 72| 1| ## ## ###### ## ## #### ## ## ###### ###### ## ## ## 73| 1| ############ ## #### ## ## ## ###### ## ## 74| 1| #### ######## ## ###### #### ## ###### #### ## #### ## 75| 1| ########## #### ###### ## ############## ## ## ## ## 76| 1| ###### ## #### ######## ## #### ################ 77| 1| ## ## ## ## ## #### ## ######## ## #### ###### ## 78| 1| #### ## ## ######## #### #### ## ###### ## ## 79| 1| ########## ## ########## ## #### #### ## ## ## #### 80| 1| ## ############## #### #### ## #### ###### ## #### 81| 1| ## ## ######## ## ## ## ## 82| 1| ## ########## ######## #### ## ############ ## ## #### 83| 1| ## ## ## ###### #### #### ###### #### ## #### 84| 1| ## #### #### ###### ## ## ## ################ ## ## 85| 1| #### #### #### ###### ###### ## #### ## 86| 1| ############## ## #### ###### ## ## ## ###### ## 87| 1| ## ## #### #### ## ## #### #### #### #### 88| 1| ## ###### ## #### ###### ## ###### ################ ## 89| 1| ## ###### ## ## ######## #### ## ###### ## ## 90| 1| ## ###### ## ## ## ## #### ###### ## ## ## #### ## 91| 1| ## ## ## ## #### ###### ## ############ ## 92| 1| ############## #### ###### ## ## #### ## ###### ## ## 93| 1| 94| 1|""") 95| 1| } 96| | 97| 1| func testLowErrorCorrectLevel() { 98| 1| expect(QRCode("https://passport.bilibili.com/qrcode/h5/login?oauthKey=2f3ab118e214e7ad69683df50918a481", 99| 1| errorCorrectLevel: .L), 100| 1| withFill: "@@", andPatch: " ", 101| 1| toMatch: """ 102| 1| 103| 1| @@@@@@@@@@@@@@ @@ @@ @@ @@@@ @@ @@@@@@@@ @@@@@@@@@@@@@@ 104| 1| @@ @@ @@ @@@@@@@@ @@ @@ @@ @@ @@ @@ 105| 1| @@ @@@@@@ @@ @@@@ @@ @@@@@@@@@@ @@@@@@@@@@ @@ @@ @@ @@@@@@ @@ 106| 1| @@ @@@@@@ @@ @@@@@@ @@ @@ @@ @@@@@@@@@@ @@ @@@@@@ @@ 107| 1| @@ @@@@@@ @@ @@@@ @@ @@@@ @@ @@ @@ @@@@@@ @@ @@@@@@ @@ 108| 1| @@ @@ @@@@@@ @@@@@@@@ @@ @@ @@ 109| 1| @@@@@@@@@@@@@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@@@@@@@@@@@@@ 110| 1| @@@@ @@ @@ @@@@ @@@@ @@@@ @@@@@@ 111| 1| @@@@ @@@@@@ @@ @@@@ @@@@ @@ @@@@ @@ @@ @@@@@@@@ 112| 1| @@@@@@ @@@@@@ @@ @@ @@ @@@@@@@@ @@ @@@@ 113| 1| @@@@@@@@@@@@@@@@ @@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@ 114| 1| @@@@ @@ @@ @@ @@@@@@@@ @@ @@ @@@@ @@ 115| 1| @@ @@ @@@@@@@@ @@@@ @@@@@@ @@@@ @@ @@ @@@@@@ @@ @@ 116| 1| @@ @@ @@@@ @@ @@@@ @@@@@@@@ @@@@@@ @@@@@@@@ 117| 1| @@@@ @@@@ @@@@ @@@@@@@@@@@@ @@ @@@@@@@@ @@@@ @@ @@ 118| 1| @@ @@@@ @@ @@ @@@@@@ @@ @@ @@ @@@@ @@ @@@@@@@@@@ 119| 1| @@@@ @@@@@@@@@@ @@@@ @@@@@@@@@@ @@ @@@@ @@@@ @@@@@@ @@ @@ 120| 1| @@ @@@@ @@ @@@@@@ @@ @@@@@@@@ @@@@@@ @@@@@@@@@@ 121| 1| @@@@@@@@ @@ @@ @@ @@ @@@@ @@@@@@@@@@ @@@@ 122| 1| @@ @@@@ @@@@ @@ @@@@@@@@@@ @@@@ @@ @@ @@ @@@@ 123| 1| @@@@ @@@@@@@@ @@@@ @@@@@@@@@@@@ @@ @@ @@@@ @@@@@@@@ 124| 1| @@ @@@@@@ @@ @@ @@@@@@ @@@@@@ @@ @@ 125| 1| @@ @@ @@@@@@@@@@ @@@@@@@@@@ @@ @@@@ @@ @@ @@@@@@ 126| 1| @@ @@ @@ @@ @@ @@@@@@ @@@@ @@ @@@@@@ @@@@ 127| 1| @@@@@@ @@ @@ @@ @@@@ @@@@@@@@ @@@@@@@@ @@ @@@@ @@@@@@ 128| 1| @@@@@@ @@ @@ @@ @@@@@@ @@ @@ @@ @@ @@@@ @@ @@ 129| 1| @@@@ @@@@@@@@ @@@@@@ @@ @@@@ @@@@@@@@@@@@@@ @@ 130| 1| @@ @@ @@ @@@@@@@@ @@@@@@ @@ @@@@ @@@@ 131| 1| @@@@ @@@@@@ @@ @@@@ @@@@@@@@ @@ @@@@ @@@@@@@@@@@@@@@@@@ 132| 1| @@ @@ @@ @@ @@@@ @@ @@ @@ 133| 1| @@@@@@@@@@@@@@ @@ @@@@@@@@@@ @@ @@@@@@@@@@ @@ @@ @@ 134| 1| @@ @@ @@ @@@@ @@ @@ @@@@ @@ @@ @@@@@@ @@ @@ @@ 135| 1| @@ @@@@@@ @@ @@ @@@@ @@@@ @@ @@@@ @@ @@@@@@@@@@@@@@@@@@ 136| 1| @@ @@@@@@ @@ @@@@@@ @@ @@ @@ @@@@ @@@@@@ @@@@ 137| 1| @@ @@@@@@ @@ @@ @@@@@@@@ @@@@@@@@ @@@@ @@@@@@ 138| 1| @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@@@ 139| 1| @@@@@@@@@@@@@@ @@@@@@@@ @@@@ @@ @@@@@@@@@@@@ @@ @@@@@@@@@@@@@@ 140| 1| 141| 1|""") 142| 1| } 143| | 144| 1| func testBorderless() { 145| 1| expect(QRCode("https://github.com/ApolloZhu", withBorder: false), 146| 1| withFill: "MM", andPatch: " ", 147| 1| toMatch: """ 148| 1|MMMMMMMMMMMMMM MMMM MM MM MMMMMM MM MM MMMMMMMMMMMMMM 149| 1|MM MM MM MMMMMMMM MM MMMMMM MM MM MM 150| 1|MM MMMMMM MM MMMM MM MMMMMMMM MMMMMMMMMMMMMM MM MMMMMM MM 151| 1|MM MMMMMM MM MM MM MM MM MM MM MM MM MMMMMM MM 152| 1|MM MMMMMM MM MM MMMM MMMMMMMMMMMM MMMM MM MMMMMM MM 153| 1|MM MM MMMM MM MM MMMM MM MM MM 154| 1|MMMMMMMMMMMMMM MM MM MM MM MM MM MM MM MM MMMMMMMMMMMMMM 155| 1| MM MMMM MM MM MM 156| 1| MMMM MMMM MMMM MM MM MMMMMM MM MMMM 157| 1| MM MM MMMMMMMMMM MMMMMM MMMMMMMMMMMM MM MMMMMM 158| 1| MMMM MMMMMMMM MM MM MM MMMM MMMMMM MM MMMMMM 159| 1|MMMM MM MM MM MMMMMM MMMMMMMMMM MMMMMMMMMMMM 160| 1|MM MMMMMM MMMM MM MM MM MM MM MMMMMMMM MM 161| 1| MM MMMMMM MM MMMM MM MM MMMM MMMM MM 162| 1|MMMM MMMM MM MM MM MMMM MM MM 163| 1|MMMM MM MM MM MM MM MM MMMM MMMM MMMM MM 164| 1|MMMMMM MMMMMMMM MM MM MMMM MM MMMM MM MM 165| 1| MMMM MM MM MM MMMM MMMM MMMM MM MM MMMMMMMM MM 166| 1|MMMM MMMM MM MM MMMM MMMMMM MMMM MMMM MMMMMM MM 167| 1|MM MM MMMM MMMMMMMMMM MM MMMM MMMMMM MM MMMMMM 168| 1|MM MMMMMMMM MMMM MMMMMM MM MMMM MM MM MMMM 169| 1|MM MM MM MMMM MMMM MMMM MM MMMM MMMMMMMM 170| 1|MM MMMM MMMM MM MMMM MM MM MM MMMM MMMMMM 171| 1|MM MM MMMM MMMM MM MM MMMM MMMMMM 172| 1|MMMMMMMMMMMMMM MMMM MM MMMM MM MMMM MMMMMMMMMM 173| 1| MMMMMMMMMMMMMM MM MM MM MM MMMM MM 174| 1|MMMMMMMMMMMMMM MMMM MMMM MM MMMMMMMMMMMMMMMM MM MMMM 175| 1|MM MM MMMM MMMM MMMM MMMM MMMMMMMM 176| 1|MM MMMMMM MM MMMM MM MMMM MM MMMM MMMMMMMMMMMMMMMMMM 177| 1|MM MMMMMM MM MM MMMM MMMMMM MM MM MM MMMM 178| 1|MM MMMMMM MM MM MM MMMMMM MM MM MM MM MMMMMM 179| 1|MM MM MMMM MM MM MM MMMMMM 180| 1|MMMMMMMMMMMMMM MM MMMM MMMMMM MMMM MMMM MM MM 181| 1|""") 182| 1| } 183| | 184| | 185| 1| func testEFQRCode() { 186| 1| expect(QRCode("https://github.com/EyreFree/EFQRCode"), 187| 1| withFill: "WW", andPatch: " ", 188| 1| toMatch: """ 189| 1| 190| 1| WWWWWWWWWWWWWW WW WWWW WW WWWWWW WWWWWWWWWWWWWW 191| 1| WW WW WW WW WWWWWWWWWWWWWW WWWWWW WWWW WW WW 192| 1| WW WWWWWW WW WW WW WWWW WW WWWW WW WW WW WWWWWW WW 193| 1| WW WWWWWW WW WW WWWW WWWW WW WW WW WWWW WW WWWWWW WW 194| 1| WW WWWWWW WW WWWW WW WW WWWW WWWW WW WWWWWW WW 195| 1| WW WW WWWWWW WW WWWWWWWW WW WW WWWW WW WW 196| 1| WWWWWWWWWWWWWW WW WW WW WW WW WW WW WW WW WW WW WWWWWWWWWWWWWW 197| 1| WW WWWWWW WW WWWWWW WW 198| 1| WW WW WW WWWWWW WWWWWW WWWW WWWWWW WWWW 199| 1| WWWW WW WWWWWWWW WWWW WW WWWW WW WW WW WWWWWW 200| 1| WW WWWWWWWWWWWWWW WW WW WWWWWWWWWW WW WW WW WWWW WWWWWWWW 201| 1| WWWW WWWWWW WW WW WW WW WW WWWW WW WW 202| 1| WWWWWWWWWWWWWWWW WWWWWWWWWW WW WWWW WWWWWW WW 203| 1| WWWW WW WW WW WWWWWW WWWW WWWWWW WWWW WW WWWW WW WWWW 204| 1| WWWW WWWWWWWW WW WW WW WWWWWW WW WW WW 205| 1| WWWWWWWW WW WWWW WW WW WWWWWWWW WWWW WWWWWWWW WW 206| 1| WWWW WWWWWWWWWWWWWW WWWWWWWWWW WWWW WWWW WW WW WWWWWW WWWWWWWW 207| 1| WW WW WWWW WWWWWWWWWWWW WW WWWWWWWWWW WW 208| 1| WWWWWWWWWW WWWWWWWW WWWWWW WWWWWWWW WWWW WWWW WWWWWW 209| 1| WW WWWWWWWW WWWW WW WWWWWWWWWWWW WW WWWW WWWW 210| 1| WWWWWW WWWWWWWWWWWW WWWWWWWW WW WWWWWW WWWWWWWW WW 211| 1| WW WW WWWWWWWWWW WW WWWW WW WWWWWWWW WWWW WWWW 212| 1| WWWWWW WW WW WWWW WWWWWW WW WWWW WWWWWWWW WWWW 213| 1| WW WW WW WW WW WW WW WW WWWW WW WW WWWW 214| 1| WWWWWWWWWW WWWW WW WW WW WWWWWW WW WW WW WW 215| 1| WWWW WWWW WWWWWWWW WWWW WW WWWW WWWW WW WW 216| 1| WW WW WWWWWW WWWW WWWW WW WWWW WW WWWWWWWWWWWWWW WW WW 217| 1| WW WW WW WW WW WWWW WWWWWW WWWW WW WW 218| 1| WWWW WW WW WWWW WWWW WW WW WW WWWWWWWWWWWW WW 219| 1| WW WW WW WW WW WW WWWWWWWWWW WW WWWW 220| 1| WWWWWWWWWWWWWW WW WW WWWWWWWWWWWWWWWWWW WW WWWW WW WW WWWWWW 221| 1| WW WW WW WW WW WW WW WWWWWW WW WW 222| 1| WW WWWWWW WW WW WWWW WW WW WWWWWWWWWW WWWWWWWWWWWW WW 223| 1| WW WWWWWW WW WW WWWWWW WWWWWW WW WWWWWWWW WW WW WWWW 224| 1| WW WWWWWW WW WW WWWW WW WWWW WWWWWWWWWW WW WWWW WW 225| 1| WW WW WW WWWW WW WWWW WW WWWWWW WWWW WW 226| 1| WWWWWWWWWWWWWW WW WW WWWWWW WW WW WW WWWWWW WWWW WWWW 227| 1| 228| 1|""") 229| 1| } 230| | 231| 1| func testEmpty() { 232| 1| expect(QRCode("", errorCorrectLevel: .L), 233| 1| withFill: "XX", andPatch: " ", 234| 1| toMatch: """ 235| 1| 236| 1| XXXXXXXXXXXXXX XX XX XXXXXXXXXXXXXX 237| 1| XX XX XX XX XX XX 238| 1| XX XXXXXX XX XX XX XXXXXX XX 239| 1| XX XXXXXX XX XX XX XX XXXXXX XX 240| 1| XX XXXXXX XX XXXXXX XX XXXXXX XX 241| 1| XX XX XXXXXX XX XX XX 242| 1| XXXXXXXXXXXXXX XX XX XX XXXXXXXXXXXXXX 243| 1| XXXXXX 244| 1| XXXXXXXXXX XXXXXXXX XXXX XX XX XX 245| 1| XXXX XXXX XX XX XX XX 246| 1| XX XX XX XXXX XX XXXXXXXXXX 247| 1| XX XX XXXX XXXX XX XX 248| 1| XXXXXX XXXXXXXX XX XX XXXXXXXXXX 249| 1| XXXXXXXXXXXXXX XX 250| 1| XXXXXXXXXXXXXX XXXXXX XX XXXX 251| 1| XX XX XXXXXXXXXXXX XX 252| 1| XX XXXXXX XX XXXXXX XX XX XX 253| 1| XX XXXXXX XX XXXX XX XX XX 254| 1| XX XXXXXX XX XXXX XX XX XXXXXX 255| 1| XX XX XXXX XXXX XX 256| 1| XXXXXXXXXXXXXX XX XXXX XX XXXXXXXX 257| 1| 258| 1|""") 259| 1| } 260| | 261| 1| func testStressWithPI() { 262| 1| let content = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989" 263| 1| expect(QRCode(content, errorCorrectLevel: .M), 264| 1| withFill: "%%", andPatch: " ", 265| 1| toMatch: """ 266| 1| 267| 1| %%%%%%%%%%%%%% %%%%%% %%%%%%%%%%%% %%%%%%%% %%%%%% %% %% %%%% %%%% %%%%%% %% %% %%%%%% %%%% %%%%%% %% %%%%%% %% %%%%%% %% %% %% %% %% %%%% %%%%%%%%%%%%%% 268| 1| %% %% %% %% %%%%%%%% %% %% %% %% %% %% %%%% %% %%%%%%%% %% %% %%%%%%%% %% %%%% %% %%%%%%%% %% %% %%%%%%%% %% %% %%%%%%%% %% %% %% %% %% %% 269| 1| %% %%%%%% %% %% %%%% %% %%%% %% %%%% %% %%%%%%%%%% %% %%%%%%%% %% %% %%%%%%%% %% %% %%%%%%%% %% %% %%%%%%%% %%%% %% %%%%%%%% %% %%%% %% %%%%%% %% 270| 1| %% %%%%%% %% %%%%%% %%%%%% %% %% %% %%%% %%%%%% %% %%%% %% %% %% %% %% %%%%%% %% %% %% %%%% %% %%%% %% %% %%%% %% %%%%%%%% %% %%%%%%%% %% %%%%%% %% 271| 1| %% %%%%%% %% %% %%%% %% %% %% %% %%%%%%%%%%%% %%%%%%%% %%%% %% %% %% %% %%%%%%%%%% %% %%%% %%%% %% %% %%%%%%%%%%%%%% %%%% %%%% %%%% %%%% %% %% %%%%%% %% 272| 1| %% %% %%%%%%%%%%%% %% %% %% %% %% %% %% %%%%%% %% %% %%%%%%%% %% %% %%%% %% %% %%%%%%%% %% %% %% %% %% %% %%%%%%%% %% %% %%%%%%%%%%%% %% %% 273| 1| %%%%%%%%%%%%%% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %%%%%%%%%%%%%% 274| 1| %% %% %%%% %%%%%%%% %%%% %% %% %%%% %% %% %% %%%%%% %% %%%%%% %%%% %% %%%%%%%% %% %% %%%%%% %% %% %% %%%%%%%% %% %% %%%%%%%% %% %%%% 275| 1| %% %%%% %%%%%% %% %%%%%%%% %% %% %%%%%% %%%%%%%%%%%%%% %% %% %%%% %%%%%%%% %%%%%% %%%%%%%%%%%% %%%% %%%% %%%% %% %% %%%% %%%%%%%%%%%% %% %% %% %% %%%% %% %% %% %%%% 276| 1| %% %% %% %%%%%% %% %%%% %% %%%% %%%%%% %% %%%%%% %%%%%%%% %% %%%%%% %% %%%% %%%% %%%%%%%% %%%% %%%% %% %% %%%% %%%%%% %% %%%%%% %%%%%% %%%% %% 277| 1| %%%% %% %%%%%% %% %%%%%%%% %%%% %% %%%% %%%%%% %% %% %%%% %% %%%%%%%% %% %% %%%%%%%% %% %% %%%%%%%% %% %% %% %%%%%% %% %% %%%%%%%% %% %% %% %% %% %% 278| 1| %% %% %% %% %% %%%% %% %% %% %%%%%%%% %%%%%% %% %% %% %%%%%% %% %% %%%%%%%% %% %% %%%%%%%% %% %% %%%%%%%% %% %% %%%%%%%% %% %%%% %% %% 279| 1| %% %%%%%% %%%% %% %% %%%% %%%%%%%% %% %% %%%% %%%%%%%% %% %%%% %%%% %%%%%% %%%% %% %% %% %% %%%% %% %% %% %%%% %%%% %%%% %% %%%% %%%%%% %% %% %% %%%%%% 280| 1| %% %% %% %% %%%%%% %% %% %% %%%%%%%%%% %%%%%% %%%% %%%% %% %% %% %%%% %% %% %% %%%% %%%%%%%% %% %% %% %% %%%% %% %%%%%% %%%% %% %% %%%% %% %% %% 281| 1| %% %%%%%%%% %% %% %% %%%% %% %% %% %%%% %% %% %%%% %% %%%%%%%% %% %% %%%%%%%% %% %% %%%%%%%% %% %% %% %% %% %% %%%%%%%% %% %% %%%% %% %% %%%% %% 282| 1| %% %% %% %% %% %% %%%% %%%% %% %% %%%% %%%% %%%%%%%% %% %% %% %%%%%%%% %% %% %%%%%%%% %% %%%%%%%%%%%% %% %% %%%%%%%% %% %% %%%%%% %% %%%% %% 283| 1| %%%%%% %% %% %%%%%%%% %%%%%% %%%%%%%% %%%% %% %%%%%% %% %%%%%%%% %%%% %% %% %%%% %% %% %%%%%% %% %% %%%% %%%% %% %%%% %% %% %%%% %% %%%% %% %%%%%%%%%%%% 284| 1| %% %% %%%%%% %%%% %%%%%%%%%%%% %%%%%%%% %% %%%% %%%% %% %%%% %% %%%%%%%% %% %%%% %% %%%%%%%% %%%% %%%%%%%%%%%%%%%% %%%%%% %% %% %%%% %% %% %%%%%% 285| 1| %%%% %%%%%% %% %% %% %%%% %% %% %% %%%%%% %% %%%% %% %%%% %% %%%%%%%% %% %%%%%%%% %% %% %%%%%%%% %% %%%%%%%% %% %% %%%%%%%% %% %% 286| 1| %% %%%%%% %%%%%% %%%%%%%% %% %% %% %%%%%% %%%%%% %% %%%% %%%%%% %% %% %%%%%%%%%% %% %% %%%%%%%% %% %% %%%%%% %%%% %% %%%%%%%% %% %% %%%%%%%% %% %%%%%% %% %%%% 287| 1| %%%% %%%% %%%% %% %%%% %%%% %% %% %% %% %% %%%% %%%%%%%% %%%% %%%%%%%% %%%%%%%%%%%% %%%% %%%%%%%% %% %%%%%%%%%% %%%% %% %% %% %%%%%%%%%% %% %%%% %%%%%% %% 288| 1| %% %%%%%%%% %%%% %%%% %%%%%% %% %%%%%%%% %%%%%%%% %%%% %%%% %%%%%%%% %% %% %%%% %% %%%% %%%%%%%%%%%% %%%% %%%% %%%% %%%% %% %%%% %%%% %% %%%% %%%%%%%%%% %% 289| 1| %% %% %% %% %%%% %% %%%%%% %% %%%%%% %% %% %% %% %% %%%%%% %% %% %% %%%%%%%% %% %% %%%%%%%% %% %%%%%%%% %% %% %%%%%% %%%% %% %%%% %%%%%%%% 290| 1| %%%% %% %% %% %%%%%% %% %%%% %% %% %% %% %% %% %%%% %%%% %%%%%%%% %% %% %%%%%% %% %%%%%%%% %% %% %%%% %% %% %% %% %%%%%%%% %% %% %% %% %% %%%% %%%% %%%%%% 291| 1| %% %% %%%%%%%%%% %% %% %% %% %% %% %%%%%% %% %% %% %% %% %%%%%%%% %%%%%%%%%%%%%% %% %%%% %%%% %% %%%%%% %%%%%% %%%%%% %%%%%% %% %%%% %%%%%%%% %% %% %% %% 292| 1| %% %% %% %%%%%% %% %%%% %% %% %% %% %%%% %%%% %%%%%%%%%%%%%% %% %%%%%% %%%% %%%% %%%%%%%% %%%% %% %% %%%% %% %%%%%%%% %%%%%%%%%%%% %%%% %% %% %%%% 293| 1| %%%%%%%%%% %%%%%% %%%%%% %%%%%% %% %%%% %%%%%% %% %%%%%%%% %%%%%% %% %%%%%%%% %% %% %%%%%%%% %% %% %%%%%%%% %% %% %%%%%%%% %% %% %%%%%%%% %% %%%% %%%%%%%% 294| 1| %% %% %% %%%% %%%% %% %% %% %% %% %% %%%% %%%%%% %%%%%%%% %% %% %% %%%%%%%% %% %% %%%%%%%% %% %%%%%%%%%%%% %% %% %%%%%%%% %% %% %%%%%% %% %% %%%% %% 295| 1| %%%%%%%%%%%%%%%% %% %%%%%%%%%%%% %%%%%% %%%%%%%%%%%%%%%% %%%% %% %%%% %% %%%%%%%%%%%%%%%% %%%% %%%% %%%% %% %% %%%%%%%%%% %% %% %%%% %% %%%%%% %%%% %% %%%%%%%%%%%%%%%% 296| 1| %%%%%% %%%%%% %% %% %%%%%%%% %%%%%%%%%% %%%% %% %%%% %%%%%%%% %% %% %% %% %% %% %% %%%% %% %%%%%% %%%% %%%% %%%% %% %% %% %% %% %% %% %% %% 297| 1| %% %% %% %% %% %%%%%% %% %%%%%%%%%% %% %% %%%% %% %% %% %% %% %% %% %% %% %% %%%%%%%% %% %% %%%%%%%% %% %% %% %%%%%%%% %% %% %%%%%%%% %% %%%% %% %% %%%% 298| 1| %% %% %%%%%% %% %% %% %% %%%%%%%%%% %%%% %%%% %%%% %% %% %% %% %%%% %% %%%%%%%% %% %% %%%%%%%%%% %% %% %%%%%%%% %% %% %%%%%%%% %% %% %% %%%% 299| 1| %%%%%%%%%% %% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %% %%%% %%%%%%%% %% %%%%%%%% %% %% %%%%%%%%%% %%%% %%%% %% %% %%%% %% %%%%%%%%%%%% %%%% %% %% %% %% %%%%%%%% %%%%%%%%%%%% %%%% 300| 1| %% %%%% %%%%%%%%%% %%%%%% %%%% %%%% %%%%%%%% %% %%%% %%%% %%%% %%%% %%%% %% %% %%%%%%%% %% %% %% %%%%%%%%%% %% %%%% %%%% %%%% %% %% 301| 1| %%%% %%%%%%%%%% %% %% %%%%%% %% %% %%%% %%%%%%%% %%%%%%%%%% %% %% %% %% %% %%%%%%%% %% %% %%%% %% %% %%%% %% %%%% %% %% %% %% %% %% %%%% %% %%%%%% 302| 1| %%%%%%%% %% %% %%%%%% %% %% %%%%%%%%%% %% %% %% %%%% %%%% %%%%%% %% %%%%%%%% %% %% %%%%%%%% %% %% %% %% %%%%%% %% %%%% %%%%%% %% %% %%%%%%%% %% %% 303| 1| %% %%%% %%%%%%%%%%%% %%%% %% %% %%%% %%%%%%%% %%%%%%%%%%%% %%%% %%%%%%%% %%%% %% %% %% %%%% %% %%%%%% %%%% %% %%%%%% %% %% %% %% %%%%%%%% %% %% %% %% %% %% %% 304| 1| %% %%%% %% %% %%%% %%%% %% %%%%%%%%%%%% %%%%%%%%%%%%%% %%%%%%%% %% %% %%%%%% %%%%%% %% %%%% %%%%%% %%%% %%%%%%%% %%%% %% %%%% %% %% %%%%%%%%%% %%%%%%%% %% %%%%%% %% %% 305| 1| %%%%%% %%%%%% %% %%%% %% %%%%%%%%%% %% %% %% %%%%%% %%%%%%%%%% %%%%%% %%%% %%%%%% %% %% %% %%%%%%%% %% %% %% %% %%%%%% %% %%%%%%%% %% %% %%%%%%%% %%%% %%%%%% 306| 1| %% %% %%%% %%%%%%%%%%%%%% %% %%%%%%%%%%%% %% %% %% %%%%%% %%%%%%%% %% %% %% %% %%%%%% %%%% %% %%%%%%%% %% %%%%%% %% %% %% %%%%%%%% %% %% %%%%%%%%%%%% %% 307| 1| %%%% %%%% %%%%%% %% %%%%%%%% %%%% %% %% %%%% %% %% %%%%%%%% %%%% %% %%%%%% %%%% %%%%%% %% %% %%%% %% %% %%%%%% %% %%%% %%%%%%%% %%%% %% %%%% %% %% %%%% 308| 1| %% %%%% %% %%%% %%%% %%%%%%%%%% %% %%%% %%%% %% %% %% %%%% %%%%%%%% %%%% %% %%%%%%%%%% %%%%%% %% %% %% %%%% %%%%%%%% %% %%%% %%%% %%%%%% %%%%%%%% 309| 1| %% %% %%%%%% %% %%%%%%%% %%%% %% %% %%%%%% %% %%%% %%%%%%%%%%%% %% %% %% %% %% %%%%%% %% %%%%%%%% %% %% %%%%%%%% %% %%%%%%%% %% %% %%%%%%%% %% %%%%%%%% %% 310| 1| %%%%%%%% %% %%%%%%%% %%%% %%%%%%%%%%%% %%%%%% %%%%%% %% %%%% %% %%%%%% %% %% %%%%%% %%%% %% %%%%%%%% %% %% %%%%%% %%%%%% %% %%%%%%%% %% %% %%%%%%%% %%%% %% %% %%%% 311| 1| %% %%%%%%%%%%%% %%%%%% %%%% %% %% %%%%%%%%%%%% %% %% %%%%%% %% %%%%%%%% %%%% %% %%%%%% %%%%%% %%%% %% %% %%%% %% %% %% %% %%%% %%%% %% 312| 1| %% %%%%%% %%%% %%%% %%%%%% %%%%%% %%%%%%%% %%%%%% %% %%%%%%%% %%%% %% %%%% %%%%%% %%%%%% %%%% %% %% %% %%%% %% %%%% %% %% %%%%%% %% 313| 1| %%%% %%%%%% %% %%%% %%%% %%%%%% %% %% %% %% %%%%%%%% %% %% %%%%%%%% %% %%%%%%%% %% %% %%%%%%%% %% %%%% %% %% %% %% %%%%%%%% %% %% %%%% %% %% %%%%%% 314| 1| %% %%%% %% %% %% %% %%%% %% %% %% %% %% %% %% %%%%%% %%%%%% %% %%%%%%%% %% %% %%%%%%%% %% %% %% %% %%%%%% %% %% %%%%%%%% %% %% %% %% %% 315| 1| %%%% %%%%%% %% %% %%%%%%%%%% %%%% %% %% %% %%%%%% %% %%%% %%%%%%%%%% %% %% %% %%%% %%%%%%%% %% %% %% %%%%%%%% %%%% %% %% %% %% %% %%%% %% %% 316| 1| %% %% %% %% %% %% %%%%%% %%%%%%%%%% %%%% %% %% %%%%%%%%%% %% %%%% %%%%%% %% %% %%%%%% %%%%%% %%%%%%%%%% %% %% %%%% %%%% %% %% %% %% %%%% %% %% %% 317| 1| %% %%%%%%%%%% %% %%%% %% %%%% %%%%%%%%%%%%%% %% %% %%%%%%%% %%%%%%%% %% %%%% %% %% %% %% %%%%%%%% %% %% %% %% %%%% %% %%%%%%%% %% %% %%%%%%%% %%%%%% %%%% 318| 1| %%%% %%%% %%%% %%%% %%%%%% %% %% %%%%%% %% %% %%%% %%%%%%%% %%%% %%%%%%%% %% %% %%%% %%%%%% %% %% %%%%%%%% %% %%%%%% %%%% %% %%%%%%%% %% %% %%%%%%%% %% %% %%%% 319| 1| %% %%%% %%%%%% %% %%%% %% %%%%%%%% %% %% %% %%%%%%%%%%%% %% %% %% %% %% %% %%%%%%%% %% %% %% %% %%%% %%%% %% %% %%%%%% %% %%%% %% %% %%%%%%%% 320| 1| %%%% %%%% %%%%%%%% %% %% %% %%%%%% %%%%%%%% %% %%%% %%%% %% %%%%%% %%%%%%%% %%%%%% %% %% %% %%%%%% %%%% %%%% %%%%%%%%%% %%%%%%%% %%%%%% %%%%%%%% %%%%%% %%%% 321| 1| %%%%%% %%%% %%%%%% %% %% %%%%%% %%%%%%%% %% %%%% %% %% %% %% %%%% %%%% %% %% %%%% %% %% %% %% %% %%%%%%%% %%%% %% %% %% %%%%%%%% %% %% %% %% 322| 1| %% %% %% %% %% %% %%%% %% %%%%%%%%%%%% %% %%%%%% %% %% %%%%%% %%%% %%%% %%%%%% %% %% %%%%%% %%%%%% %% %%%%%%%% %% %% %%%%%%%% %% %% %%%% 323| 1| %% %%%%%%%%%% %% %%%%%%%% %%%%%% %% %%%%%%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%% %% %%%%%%%%%%%%%% %% %%%%%%%%%%%% %% %% %% %%%% %%%%%%%%%% %% %%%% %% %% %%%%%%%% %%%%%%%%%%%%%% %% 324| 1| %%%% %% %% %% %%%%%%%% %% %% %%%% %%%% %%%% %% %% %%%% %% %%%% %%%%%% %%%%%%%% %%%%%% %% %%%% %%%% %%%%%% %%%%%% %%%% %% %% %% %% %% %% %% 325| 1| %% %%%% %% %% %%%% %% %% %%%% %% %%%% %% %% %%%% %% %%%% %%%% %% %%%%%%%% %% %% %% %%%%%%%% %% %%%% %%%%%% %% %%%% %% %%%% %% %% %%%%%%%% %% %% %% %% %% %%%% %% 326| 1| %%%%%%%%%% %% %% %% %%%%%%%%%%%% %% %% %%%%%% %%%%%%%%%% %% %%%%%% %%%%%% %%%%%%%%%% %% %% %%%%%%%% %% %% %%%%%%%% %% %%%% %%%%%%%% %% %%%%%%%% %% %%%%%% %% %%%% 327| 1| %%%%%%%%%%%%%%%%%% %% %% %% %% %%%% %% %%%%%%%%%%%%%% %%%%%%%%%% %% %%%% %% %% %%%%%%%%%% %%%% %% %% %%%% %% %%%%%%%%%% %% %% %% %% %%%% %%%%%%%%%% %% 328| 1| %%%%%%%%%%%% %% %% %%%% %%%%%%%% %%%% %%%%%% %% %%%%%%%% %%%% %% %%%% %%%% %% %%%%%% %% %% %%%% %% %% %%%% %% %%%% %% %%%% %% %%%% %% %%%%%%%% %% %% 329| 1| %%%%%%%%%% %%%%%%%%%% %%%% %%%% %%%% %%%%%%%% %%%%%% %%%% %%%%%%%%%%%% %%%%%% %% %% %% %% %% %%%%%%%% %% %% %% %% %% %% %%%%%%%% %% %% %%%%%%%% %%%%%%%% %% 330| 1| %%%% %%%%%% %%%% %% %% %% %%%% %%%%%%%%%%%%%% %% %% %% %%%%%%%% %% %% %% %%%%%% %% %% %%%%%%%% %% %% %%%% %% %% %%%%%%%% %% %% %%%%%%%% %%%%%% %%%% 331| 1| %%%% %%%%%%%% %% %% %% %%%% %%%% %%%%%% %%%% %% %%%% %% %% %%%%%%%% %%%% %% %%%% %% %%%% %% %%%%%% %%%% %%%%%%%% %% %% %%%% %% %% %%%%%% %% %%%%%%%% 332| 1| %%%% %% %% %%%% %% %% %% %% %% %%%% %% %%%% %%%% %% %% %% %%%% %%%%%%%% %%%% %% %%%% %%%% %%%% %% %% %% %% %% %%%%%% %%%% %%%% %%%%%%%%%%%% 333| 1| %% %%%% %%%% %%%%%%%%%%%%%%%% %%%% %%%%%% %% %% %%%% %%%% %% %% %% %%%% %% %%%%%%%% %% %% %%%%%%%% %% %% %%%%%%%% %% %% %%%%%%%% %% %%%%%% %% %% 334| 1| %%%% %%%%%% %%%% %%%% %%%% %% %% %% %%%%%% %% %% %% %% %% %% %%%% %% %% %%%%%%%% %% %% %%%%%%%%%% %%%% %% %%%%%%%% %% %% %%%%%%%% %% %%%%%% %% 335| 1| %%%%%%%%%%%% %%%%%% %%%%%%%%%%%% %%%%%%%%%% %% %% %% %% %% %% %% %%%% %% %% %% %%%% %%%%%%%% %% %% %%%% %% %%%%%%%%%% %% %% %% %% %% 336| 1| %% %% %%%%%%%% %% %% %% %% %%%% %% %% %%%% %%%%%%%% %% %%%%%% %%%% %% %%%% %% %% %%%% %% %% %% %%%%%% %% %% %% %% %% %%%%%%%%%%%% 337| 1| %%%%%%%%%% %% %% %% %% %%%%%%%% %% %%%%%%%% %% %% %% %%%%%%%% %% %%%% %%%%%%%% %% %% %%%%%%%% %% %% %%%%%% %% %% %% %%%%%%%% %%%% %% %% %%%% %% 338| 1| %%%% %%%%%% %% %% %% %%%% %% %%%%%%%%%%%%%% %% %% %%%%%% %% %%%%%%%%%% %% %%%%%%%%%% %%%%%% %%%%%%%% %% %% %%%%%% %%%% %%%% %%%%%%%%%%%% %% %% %%%%%%%% %% %% %%%%%% %% %%%%%% 339| 1| %% %% %%%%%%%%%% %%%%%%%% %% %%%%%% %% %%%%%% %%%%%% %% %% %%%%%%%% %%%%%% %% %% %%%% %% %%%% %% %% %% %%%% %% %%%%%% %% %% %%%%%% %% %% %% %%%%%% 340| 1| %%%% %%%% %%%%%% %% %%%% %% %%%%%% %% %%%%%%%%%% %%%% %%%% %% %%%%%% %% %%%% %%%%%% %% %% %%%% %% %%%% %% %%%% %% %% %%%%%% %%%% %% %% %% 341| 1| %% %% %%%% %%%%%% %% %%%% %%%%%% %% %% %% %%%% %% %%%%%% %% %% %%%%%%%% %%%% %% %%%%%%%% %% %% %% %% %% %%%%%%%% %% %% %%%%%%%% %%%%%%%%%%%% 342| 1| %%%% %% %% %%%%%% %%%% %% %% %%%% %%%% %%%%%% %%%% %%%%%%%% %% %%%%%%%% %% %% %% %%%%%%%% %% %%%%%%%%%%%% %% %% %%%%%%%% %% %% %%%%%%%% %%%%%%%% %% 343| 1| %% %%%% %% %%%% %%%%%% %%%%%%%% %%%% %% %% %%%%%% %% %% %%%% %%%%%%%%%% %% %%%% %%%% %% %%%%%%%%%% %%%% %% %%%%%% %% %%%% %%%%%% %%%%%% %%%%%%%% %% %%%%%%%%%% 344| 1| %% %%%%%%%% %% %%%%%% %%%%%%%%%%%%%% %% %%%%%%%% %%%%%%%% %% %%%%%%%% %% %%%%%% %% %%%% %% %% %%%%%% %%%%%%%%%%%%%% %% %%%%%% %%%% %%%%%% %%%% %% %% %% %%%%%% 345| 1| %% %%%%%% %% %% %% %%%% %% %%%%%% %% %% %% %% %%%%%% %% %% %% %% %% %%%%%%%% %% %% %%%%%%%% %% %%%%%%%% %% %% %%%%%% %%%% %% %% 346| 1| %% %% %% %% %% %%%%%% %%%% %% %% %% %% %%%%%%%% %% %%%%%%%%%% %% %% %%%%%%%% %% %% %%%% %% %% %%%%%%%% %% %% %% %% %% %% %% %%%% 347| 1| %%%%%% %% %% %% %%%%%%%% %%%% %% %%%%%%%% %%%%%%%%%%%% %% %% %% %% %%%%%%%%%%%%%% %%%% %%%%%%%%%% %%%%%% %% %% %% %%%%%%%%%% %%%% %%%%%% %% %%%% 348| 1| %%%%%% %%%% %%%% %% %%%%%%%%%%%%%% %% %%%%%% %% %% %%%% %%%% %% %%%% %%%%%%%% %% %%%% %%%%%% %%%%%%%% %%%%%% %% %% %%%% %%%% %%%%%% %% %% %%%% %%%%%% 349| 1| %%%%%%%%%%%%%% %% %%%% %%%%%% %%%% %% %% %% %% %%%%%%%% %% %% %%%%%%%% %% %% %%%%%%%% %% %% %%%% %%%% %% %% %%%%%%%% %% %% %% %% %% %%%% 350| 1| %% %%%% %% %%%%%% %%%% %%%% %%%%%% %% %% %% %%%% %%%%%% %%%%%%%% %% %%%%%%%%%% %%%% %% %%%%%%%% %% %% %%%%%%%% %% %%%%%%%%%% %% %% %%%%%%%% %% %% %% %% %% 351| 1| %% %%%%%%%%%%%% %% %% %% %% %% %%%%%%%%%%%%%% %% %% %% %% %%%% %% %%%% %%%%%%%%%%%%%%%%%% %% %%%% %% %%%% %%%%%%%%%% %% %%%% %% %% %%%%%%%%%% %%%%%% 352| 1| %% %% %%%% %% %% %% %% %% %% %% %% %% %% %%%% %%%% %%%% %% %% %%%% %%%% %% %%%%%%%% %%%% %% %% %% %% %%%% %%%% %% %% %% 353| 1| %% %%%% %% %%%%%% %%%% %% %% %% %% %% %% %% %% %%%%%% %%%%%%%%%% %% %%%%%% %% %% %% %%%% %% %% %%%%%%%% %% %% %%%%%% %% %% %% %%%%%%%% %% %% %%%%%%%% %% %% %%%%%% 354| 1| %% %%%% %% %%%%%% %%%%%%%% %% %% %%%% %%%%%% %%%%%%%%%% %% %%%%%%%% %% %%%% %%%%%%%% %% %% %%%%%%%% %% %%%%%% %%%% %% %%%%%%%% %% %% %%%%%%%%%% %%%% %% 355| 1| %% %%%%%%%%%%%%%% %%%% %%%% %% %% %% %% %%%%%%%%%%%%%%%% %%%%%%%% %% %%%%%% %%%% %%%%%% %%%%%%%%%% %%%% %% %%%%%% %% %% %%%%%%%%%%%% %%%% %% %%%%%% %% %%%%%%%%%%%%%%%%%%%% 356| 1| %% %%%% %% %% %%%%%% %%%%%%%% %% %% %% %% %% %%%%%% %%%% %%%%%%%%%% %%%%%%%% %% %%%%%% %%%% %%%% %%%% %% %%%%%% %% %%%%%% %%%% %% %% %% %% %% %%%%%%%% 357| 1| %%%% %%%% %%%%%% %% %%%%%%%%%% %%%%%%%%%% %% %%%%%% %%%%%% %% %% %% %% %% %% %% %%%%%%%% %%%% %% %%%%%%%% %%%%%%%% %%%%%%%% %% %% %%%%%%%% %% %%%% %%%% %% 358| 1| %%%% %% %% %%%% %%%% %% %%%%%% %% %% %%%% %%%% %% %%%% %%%% %% %% %% %%%%%%%% %% %% %%%%%% %% %% %% %%%%%% %%%% %% %%%%%%%% %% %% %% %% %% 359| 1| %%%% %% %% %% %%%%%%%%%% %%%% %% %%%% %% %% %% %% %% %%%% %% %% %% %%%% %% %%%%%% %% %%%%%% %% %% %% %% %% %% %%%%%%%% %%%% %%%% %% 360| 1| %%%% %%%% %% %% %% %% %%%% %% %% %% %% %%%%%% %% %% %%%% %% %% %% %% %% %% %%%% %%%% %% %% %% %% %%%%%% %% %% %%%% %% %% %% 361| 1| %%%%%%%% %%%% %%%%%% %%%% %%%%%%%% %% %%%%%%%%%%%% %% %% %% %%%% %%%%%%%% %%%%%%%% %%%%%%%% %% %% %%%%%%%% %% %% %% %% %% %%%% %% %%%%%%%% %% %% %% %%%% %%%% 362| 1| %%%% %% %%%%%%%%%% %%%% %%%% %%%% %%%% %% %% %%%%%% %% %%%%%%%%%% %%%%%% %% %%%%%%%% %%%% %% %%%%%%%% %% %% %%%%%% %% %% %%%%%%%% %% %%%%%%%%%%%% %%%% 363| 1| %%%%%% %%%%%%%% %%%% %% %%%%%%%%%%%%%%%%%% %%%% %% %%%%%% %% %%%% %%%%%% %% %%%%%% %% %%%% %%%%%%%%%% %% %%%%%%%%%%%%%%%% %% %% %% %% %%%% %%%%%%%% %%%% %%%%%% %%%%%% 364| 1| %% %% %%%% %% %%%% %%%%%%%% %%%% %%%%%%%%%%%% %% %%%%%% %%%%%% %% %% %% %% %%%% %% %% %% %% %%%% %% %%%%%%%% %%%%%% %%%% %%%%%%%% %% %% %%%% %% 365| 1| %% %% %% %% %% %% %%%% %%%%%%%%%%%% %%%% %% %% %%%%%%%% %% %% %% %% %% %%%%%%%% %% %% %% %% %% %% %% %%%%%%%% %% %% %%%%%%%% %% %% %% 366| 1| %%%% %% %% %%%% %%%% %% %% %%%%%%%% %% %%%% %% %% %%%%%%%% %% %% %%%%%%%% %% %% %%%%%%%% %% %% %% %% %%%%%%%% %% %% %%%%%% %% %% 367| 1| %% %% %% %% %% %% %%%% %%%% %%%% %% %%%%%% %%%% %% %% %% %%%% %% %%%% %%%%%%%%%% %%%% %% %%%%%% %%%% %% %%%%%%%% %% %% %%%%%% %%%%%%%%%% %% %% %% %%%% 368| 1| %%%% %% %%%% %% %% %%%% %%%%%%%%%%%% %%%%%% %% %%%%%% %%%%%% %%%% %% %%%%%% %%%%%%%%%% %% %% %%%%%%%%%% %% %%%% %%%% %% %% %% %% %% %% %%%% %%%% %%%% 369| 1| %%%% %%%%%% %%%%%%%%%%%%%% %%%% %%%% %%%%%%%% %%%%%%%% %% %%%% %%%%%% %% %%%% %% %% %% %%%%%%%% %% %% %%%%%%%% %% %%%%%% %%%%%%%% %% %% %%%%%%%% %% %%%% %% %% %% 370| 1| %%%% %% %%%% %%%% %% %% %% %% %%%%%% %% %%%%%% %%%%%%%%%%%% %% %% %% %% %% %% %%%%%%%% %% %% %%%%%%%%%%%%%% %% %% %%%%%%%% %% %% %%%%%%%% %% %% %% %% 371| 1| %% %% %%%%%%%%%% %%%%%%%%%% %%%%%%%% %%%%%%%% %%%% %% %% %%%% %% %% %% %%%%%% %% %%%%%% %% %%%% %% %% %%%% %% %% %%%% %%%% %% %%%% %% 372| 1| %% %%%% %%%% %% %%%% %% %% %% %%%% %%%% %%%%%%%%%% %% %%%% %% %% %% %% %%%% %% %% %% %% %%%% %%%% %%%% %% %%%% %%%% %% %% %% %% %% 373| 1| %%%%%% %%%%%% %% %%%%%% %% %% %% %% %%%% %% %%%%%%%% %% %%%% %%%%%%%% %% %%%%%%%% %%%%%%%%%% %%%%%%%% %% %% %%%%%%%% %% %% %% %% %% %% %%%%%%%% %% %% %% %%%% %%%%%%%% 374| 1| %%%%%% %% %% %%%%%% %%%%%% %%%% %% %%%%%%%% %% %% %%%% %%%%%%%% %% %%%%%%%%%% %%%%%% %% %%%%%%%% %% %% %%%%%%%% %% %%%%%%%%%%%%%%%% %% %% %%%%%%%% %% %%%% %%%%%%%%%%%%%% %% 375| 1| %% %% %%%%%%%% %%%%%% %%%%%% %% %% %% %% %% %%%%%%%% %%%% %%%% %% %% %% %%%% %%%%%% %%%% %% %% %%%% %% %%%% %%%% %% %% %% %%%% %%%%%% %% 376| 1| %% %% %%%% %%%%%%%%%% %%%% %%%%%%%%%% %%%%%%%% %% %% %% %%%%%% %%%%%% %%%%%% %%%% %% %% %%%%%%%% %% %%%% %%%% %%%%%% %% %% %%%%%% %% %%%%%% %% %%%% %% 377| 1| %%%% %% %%%%%%%% %%%%%%%% %% %% %%%%%% %% %% %%%% %% %% %%%%%% %%%%%% %% %%%% %% %% %% %% %%%%%%%% %% %% %%%% %% %% %% %%%%%%%% %% %% %%%%%%%% %%%% 378| 1| %% %%%%%%%% %% %%%% %% %% %% %%%% %% %% %%%%%%%%%%%%%%%% %%%%%%%%%% %%%%%%%% %% %%%% %%%%%% %%%% %% %%%%%%%% %% %% %% %% %%%%%%%% %% %% %%%%%% %% %% %% 379| 1| %%%%%% %%%% %%%%%%%%%% %%%%%% %% %%%%%% %%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%% %% %% %%%%%%%%%%%% %%%% %%%%%% %%%%%% %% %%%%%%%%%%%% %%%% %%%%%% %% %% %% %%%%%%%%%% %%%%%%%%%%%%%%%%%% 380| 1| %% %% %% %%%% %% %%%%%% %% %%%% %%%% %%%% %%%%%% %% %%%% %%%% %%%% %% %%%%%% %%%% %%%%%%%%%% %% %%%% %% %%%% %%%% %%%% %% %%%% %%%%%% %% %%%%%% 381| 1| %%%%%%%%%%%%%% %%%%%% %%%%%% %%%%%% %% %%%% %% %%%%%%%%%% %% %%%%%%%% %% %% %% %% %% %% %% %%%%%%%% %% %%%% %%%%%% %% %% %% %%%%%%%% %% %% %%%%%%%% %% %% %% %%%% %% 382| 1| %% %% %%%% %%%% %%%%%% %% %% %% %% %%%%%% %%%% %% %%%%%% %%%%%% %% %%%% %%%% %% %%%%%%%% %% %% %%%%%%%%%% %% %% %%%%%%%% %% %%%%%%%% %% %%%% %% 383| 1| %% %%%%%% %% %% %% %% %%%% %%%%%%%%%% %%%%%%%%%%%%%%%% %% %% %% %%%% %% %%%% %% %%%%%%%%%%%% %%%% %%%%%%%% %% %% %% %% %% %%%%%%%%%% %%%% %% %%%%%%%%%% %% %%%%%% %%%%%%%%%%%% %% 384| 1| %% %%%%%% %% %%%% %% %% %% %% %% %% %%%% %%%%%%%% %%%% %% %% %%%% %%%% %%%% %%%% %%%% %% %%%%%%%% %% %% %% %% %% %%%% %% %%%%%%%%%% %%%%%% %% %%%% %% 385| 1| %% %%%%%% %% %% %%%%%% %%%%%%%% %%%% %%%% %%%% %%%% %%%%%% %% %% %%%%%%%% %% %% %%%%%%%% %% %% %%%%%%%% %% %%%%%%%% %% %% %%%%%%%% %% %% %% %%%%%%%% 386| 1| %% %% %%%% %%%% %% %%%% %% %% %%%% %%%%%% %%%%%%%%%% %% %%%%%%%% %% %% %%%%%%%% %% %% %%%%%%%% %% %% %%%%%%%% %% %% %%%%%%%% %% %%%%%% %% %% 387| 1| %%%%%%%%%%%%%% %%%% %% %% %%%% %% %%%%%% %% %% %%%%%%%% %% %%%% %% %%%% %% %%%%%%%% %%%% %% %% %%%% %%%%%% %% %%%% %%%%%% %%%%%% %% %%%%%% 388| 1| 389| 1|""") 390| 1| } 391| | 392| 1| func testTooLarge() { 393| 4| for (level, max) in zip(QRErrorCorrectLevel.allCases, [2953, 2331, 1663, 1273]) { 394| 4| let length = max + 1 395| 4| print("Try overflow error correct level \(level) with length of \(length)") 396| 4| let content = randomStringOfUTF8Length(length) 397| 4| print("Generated random string of length \(content.count), utf8 count \(content.utf8.count)") 398| 4| XCTAssertNil(QRCode(content, errorCorrectLevel: level)) 399| 4| } 400| 1| } 401| | 402| 1| func testAllLevelMax() { 403| 41| for limits in ([[0, 0, 0, 0]] + QRCodeType.QRCodeLimitLength).lazy.reversed() { 404| 164| for (level, length) in zip(QRErrorCorrectLevel.allCases, limits) { 405| 164| print("Try error correct level \(level), utf8 count: \(length)") 406| 164| let content = randomStringOfUTF8Length(length) 407| 164| print("Generated a random string, str length: \(content.count)") 408| 164| let qrCode = QRCode(content, errorCorrectLevel: level) 409| 164| XCTAssertNotNil(qrCode!) 410| 164| } 411| 41| } 412| 1| } 413| | 414| | static var allTests = [ 415| | ("testSimple", testSimple), 416| | ("testLowErrorCorrectLevel", testLowErrorCorrectLevel), 417| | ("testBorderless", testBorderless), 418| | ("testTooLarge", testTooLarge), 419| | ("testAllLevelMax", testAllLevelMax), 420| | ] 421| |} <<<<<< EOF # path=./swift_qrcodejs.framework.coverage.txt /Users/travis/build/ApolloZhu/swift_qrcodejs/Sources/AnError.swift: 1| |/* 2| | Copyright (c) 2017-2019 ApolloZhu 3| | 4| | Permission is hereby granted, free of charge, to any person obtaining a copy 5| | of this software and associated documentation files (the "Software"), to deal 6| | in the Software without restriction, including without limitation the rights 7| | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8| | copies of the Software, and to permit persons to whom the Software is 9| | furnished to do so, subject to the following conditions: 10| | 11| | The above copyright notice and this permission notice shall be included in all 12| | copies or substantial portions of the Software. 13| | 14| | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15| | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16| | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17| | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18| | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19| | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20| | SOFTWARE. 21| | */ 22| | 23| |struct AnError: Error { 24| | let localizedDescription: String 25| 4| init(_ description: String) { 26| 4| localizedDescription = description 27| 4| } 28| |} /Users/travis/build/ApolloZhu/swift_qrcodejs/Sources/BCHUtil.swift: 1| |/* 2| | Copyright (c) 2012 davidshimjs 3| | Copyright (c) 2017-2019 ApolloZhu 4| | 5| | Permission is hereby granted, free of charge, to any person obtaining a copy 6| | of this software and associated documentation files (the "Software"), to deal 7| | in the Software without restriction, including without limitation the rights 8| | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9| | copies of the Software, and to permit persons to whom the Software is 10| | furnished to do so, subject to the following conditions: 11| | 12| | The above copyright notice and this permission notice shall be included in all 13| | copies or substantial portions of the Software. 14| | 15| | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16| | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17| | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18| | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19| | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20| | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21| | SOFTWARE. 22| | */ 23| | 24| |struct BCHUtil { 25| | private static let g15 = 0b10100110111 26| | private static let g18 = 0b1111100100101 27| | private static let g15Mask = 0b101010000010010 28| | private static let g15BCHDigit = bchDigit(of: g15) 29| | private static let g18BCHDigit = bchDigit(of: g18) 30| | 31| 1.53k| static func bchTypeInfo(of data: Int) -> Int { 32| 1.53k| var d = data << 10 33| 5.35k| while bchDigit(of: d) - g15BCHDigit >= 0 { 34| 3.82k| d ^= (g15 << (bchDigit(of: d) - g15BCHDigit)) 35| 3.82k| } 36| 1.53k| return ((data << 10) | d) ^ g15Mask 37| 1.53k| } 38| | 39| 1.23k| static func bchTypeNumber(of data: Int) -> Int { 40| 1.23k| var d = data << 12 41| 4.94k| while bchDigit(of: d) - g18BCHDigit >= 0 { 42| 3.70k| d ^= (g18 << (bchDigit(of: d) - g18BCHDigit)) 43| 3.70k| } 44| 1.23k| return (data << 12) | d 45| 1.23k| } 46| | 47| 17.8k| private static func bchDigit(of data: Int) -> Int { 48| 17.8k| var digit = 0 49| 17.8k| var data = UInt(data) 50| 259k| while data != 0 { 51| 241k| digit += 1 52| 241k| data >>= 1 53| 241k| } 54| 17.8k| return digit 55| 17.8k| } 56| |} /Users/travis/build/ApolloZhu/swift_qrcodejs/Sources/QR8bitByte.swift: 1| |/* 2| | Copyright (c) 2012 davidshimjs 3| | Copyright (c) 2017-2019 ApolloZhu 4| | Copyright (c) 2017 EyreFree 5| | 6| | Permission is hereby granted, free of charge, to any person obtaining a copy 7| | of this software and associated documentation files (the "Software"), to deal 8| | in the Software without restriction, including without limitation the rights 9| | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10| | copies of the Software, and to permit persons to whom the Software is 11| | furnished to do so, subject to the following conditions: 12| | 13| | The above copyright notice and this permission notice shall be included in all 14| | copies or substantial portions of the Software. 15| | 16| | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17| | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18| | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19| | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20| | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21| | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22| | SOFTWARE. 23| | */ 24| | 25| |import Foundation 26| | 27| |struct QR8bitByte { 28| | let mode: QRMode = .bitByte8 29| | let parsedData: Data 30| | 31| 170| init?(_ data: String, encoding: String.Encoding = .utf8) { 32| 170| guard let parsed = data.data(using: encoding) else { 33| 0| return nil 34| 170| } 35| 170| self.parsedData = parsed 36| 170| } 37| | 38| 170| var count: Int { 39| 170| return parsedData.count 40| 170| } 41| | 42| 170| func write(to buffer: inout QRBitBuffer) { 43| 123k| for datium in parsedData { 44| 123k| buffer.put(UInt(datium), length: 8) 45| 123k| } 46| 170| } 47| |} /Users/travis/build/ApolloZhu/swift_qrcodejs/Sources/QRBitBuffer.swift: 1| |/* 2| | Copyright (c) 2012 davidshimjs 3| | Copyright (c) 2017-2019 ApolloZhu 4| | 5| | Permission is hereby granted, free of charge, to any person obtaining a copy 6| | of this software and associated documentation files (the "Software"), to deal 7| | in the Software without restriction, including without limitation the rights 8| | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9| | copies of the Software, and to permit persons to whom the Software is 10| | furnished to do so, subject to the following conditions: 11| | 12| | The above copyright notice and this permission notice shall be included in all 13| | copies or substantial portions of the Software. 14| | 15| | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16| | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17| | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18| | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19| | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20| | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21| | SOFTWARE. 22| | */ 23| | 24| |struct QRBitBuffer { 25| | var buffer = [UInt]() 26| | private(set) var bitCount = 0 27| | 28| 0| func get(index: Int) -> Bool { 29| 0| let bufIndex = index / 8 30| 0| return ((buffer[bufIndex] >> (7 - index % 8)) & 1) == 1 31| 0| } 32| | 33| 0| subscript(index: Int) -> Bool { 34| 0| return get(index: index) 35| 0| } 36| | 37| 123k| mutating func put(_ num: UInt, length: Int) { 38| 989k| for i in 0..> (length - i - 1)) & 1) == 1) 40| 989k| } 41| 123k| } 42| | 43| 989k| mutating func put(_ bit: Bool) { 44| 989k| let bufIndex = bitCount / 8 45| 989k| if buffer.count <= bufIndex { 46| 123k| buffer.append(0) 47| 989k| } 48| 989k| if bit { 49| 526k| buffer[bufIndex] |= (UInt(0x80) >> (bitCount % 8)) 50| 989k| } 51| 989k| bitCount += 1 52| 989k| } 53| |} /Users/travis/build/ApolloZhu/swift_qrcodejs/Sources/QRCode.swift: 1| |/* 2| | Copyright (c) 2017-2019 ApolloZhu 3| | 4| | Permission is hereby granted, free of charge, to any person obtaining a copy 5| | of this software and associated documentation files (the "Software"), to deal 6| | in the Software without restriction, including without limitation the rights 7| | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8| | copies of the Software, and to permit persons to whom the Software is 9| | furnished to do so, subject to the following conditions: 10| | 11| | The above copyright notice and this permission notice shall be included in all 12| | copies or substantial portions of the Software. 13| | 14| | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15| | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16| | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17| | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18| | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19| | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20| | SOFTWARE. 21| | */ 22| | 23| | 24| |/// QRCode abstraction and generator. 25| |open class QRCode { 26| | /// Content. 27| | public let text: String 28| | /// Error correct level. 29| | public let correctLevel: QRErrorCorrectLevel 30| | /// If the image codes has a border around its content. 31| | public let hasBorder: Bool 32| | private let typeNumber: Int 33| | private let model: QRCodeModel 34| | 35| | /// Construct a QRCode instance. 36| | /// 37| | /// - Parameters: 38| | /// - text: content of the QRCode. 39| | /// - encoding: encoding used for generating data from text. 40| | /// - errorCorrectLevel: error correct level, defaults to high. 41| | /// - hasBorder: if the image codes has a border around, defaults and suggests to be true. 42| | /// 43| | /// - Warning: Is computationally intensive. 44| | public init?(_ text: String, 45| | encoding: String.Encoding = .utf8, 46| | errorCorrectLevel: QRErrorCorrectLevel = .H, 47| 174| withBorder hasBorder: Bool = true) { 48| 174| guard let typeNumber = try? QRCodeType.typeNumber(of: text, errorCorrectLevel: errorCorrectLevel) 49| 174| , let model = QRCodeModel(text: text, encoding: encoding, typeNumber: typeNumber, errorCorrectLevel: errorCorrectLevel) 50| 174| else { return nil } 51| 170| self.typeNumber = typeNumber 52| 170| self.model = model 53| 170| self.text = text 54| 170| self.correctLevel = errorCorrectLevel 55| 170| self.hasBorder = hasBorder 56| 170| } 57| | 58| | /// QRCode in binary form. 59| 6| open private(set) lazy var imageCodes: [[Bool]] = { 60| 6| if hasBorder { 61| 5| let line = [[Bool](repeating: false, count: model.moduleCount + 2)] 62| 253| return line + (0.. String { 84| 296| return String(imageCodes.reduce("") { $0 + 85| 21.3k| "\($1.reduce("") { "\($0)\($1 ? black : white)" })\n" 86| 296| }.dropLast()) 87| 6| } 88| |} /Users/travis/build/ApolloZhu/swift_qrcodejs/Sources/QRCodeModel.swift: 1| |/* 2| | Copyright (c) 2012 davidshimjs 3| | Copyright (c) 2017-2019 ApolloZhu 4| | Copyright (c) 2017 EyreFree 5| | 6| | Permission is hereby granted, free of charge, to any person obtaining a copy 7| | of this software and associated documentation files (the "Software"), to deal 8| | in the Software without restriction, including without limitation the rights 9| | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10| | copies of the Software, and to permit persons to whom the Software is 11| | furnished to do so, subject to the following conditions: 12| | 13| | The above copyright notice and this permission notice shall be included in all 14| | copies or substantial portions of the Software. 15| | 16| | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17| | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18| | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19| | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20| | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21| | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22| | SOFTWARE. 23| | */ 24| | 25| |struct QRCodeModel { 26| | let typeNumber: Int 27| | let errorCorrectLevel: QRErrorCorrectLevel 28| | private var modules: [[Bool?]]! = nil 29| | private(set) var moduleCount = 0 30| | private let encodedText: QR8bitByte 31| | private var dataCache: [Int] 32| | 33| 170| init?(text: String, encoding: String.Encoding = .utf8, typeNumber: Int, errorCorrectLevel: QRErrorCorrectLevel) { 34| 170| 35| 170| guard let encoded = QR8bitByte(text, encoding: encoding) else { 36| 0| return nil 37| 170| } 38| 170| 39| 170| self.encodedText = encoded 40| 170| self.typeNumber = typeNumber 41| 170| self.errorCorrectLevel = errorCorrectLevel 42| 170| guard let dataCache = try? QRCodeModel.createData( 43| 170| typeNumber: typeNumber, 44| 170| errorCorrectLevel: errorCorrectLevel, 45| 170| data: encodedText) else { 46| 0| return nil 47| 170| } 48| 170| self.dataCache = dataCache 49| 170| makeImpl(isTest: false, maskPattern: getBestMaskPattern()) 50| 170| } 51| | 52| | /// Please be aware of index out of bounds error yourself. 53| 272M| public func isDark(_ row: Int, _ col: Int) -> Bool { 54| 272M| return modules?[row][col] == true 55| 272M| } 56| | 57| 15.7M| public func isLight(_ row: Int, _ col: Int) -> Bool { 58| 15.7M| return !isDark(row, col) 59| 15.7M| } 60| | 61| 1.53k| private mutating func makeImpl(isTest test: Bool, maskPattern: QRMaskPattern) { 62| 1.53k| moduleCount = typeNumber * 4 + 17 63| 1.53k| modules = [[Bool?]](repeating:[Bool?](repeating: nil, count: moduleCount), count: moduleCount) 64| 1.53k| setupPositionProbePattern(0, 0) 65| 1.53k| setupPositionProbePattern(moduleCount - 7, 0) 66| 1.53k| setupPositionProbePattern(0, moduleCount - 7) 67| 1.53k| setupPositionAdjustPattern() 68| 1.53k| setupTimingPattern() 69| 1.53k| setupTypeInfo(isTest: test, maskPattern: maskPattern.rawValue) 70| 1.53k| if typeNumber >= 7 { 71| 1.23k| setupTypeNumber(isTest: test) 72| 1.53k| } 73| 1.53k| mapData(dataCache, maskPattern: maskPattern) 74| 1.53k| } 75| | 76| 4.59k| private mutating func setupPositionProbePattern(_ row: Int, _ col: Int) { 77| 41.3k| for r in -1...7 { 78| 41.3k| if row + r <= -1 || moduleCount <= row + r { 79| 4.59k| continue 80| 36.7k| } 81| 330k| for c in -1...7 { 82| 330k| if col + c <= -1 || moduleCount <= col + c { 83| 36.7k| continue 84| 293k| } 85| 293k| if (0 <= r && r <= 6 && (c == 0 || c == 6)) 86| 293k| || (0 <= c && c <= 6 && (r == 0 || r == 6)) 87| 293k| || (2 <= r && r <= 4 && 2 <= c && c <= 4) { 88| 151k| modules[row + r][col + c] = true 89| 293k| } else { 90| 142k| modules[row + r][col + c] = false 91| 293k| } 92| 293k| } 93| 36.7k| } 94| 4.59k| } 95| | 96| 1.53k| private mutating func setupTimingPattern() { 97| 121k| for i in 8..> i) & 1) == 1) 133| 22.1k| modules[i / 3][i % 3 + moduleCount - 8 - 3] = mod 134| 22.1k| modules[i % 3 + moduleCount - 8 - 3][i / 3] = mod 135| 22.1k| } 136| 1.23k| } 137| | 138| 1.53k| private mutating func setupTypeInfo(isTest test: Bool, maskPattern: Int) { 139| 1.53k| let data = (errorCorrectLevel.rawValue << 3) | maskPattern 140| 1.53k| let bits: Int = BCHUtil.bchTypeInfo(of: data) // To enforce signed shift 141| 22.9k| for i in 0..<15 { 142| 22.9k| let mod = !test && ((bits >> i) & 1) == 1 143| 22.9k| 144| 22.9k| if i < 6 { 145| 9.18k| modules[i][8] = mod 146| 22.9k| } else if i < 8 { 147| 3.06k| modules[i + 1][8] = mod 148| 22.9k| } else { 149| 19.8k| modules[moduleCount - 15 + i][8] = mod 150| 22.9k| } 151| 22.9k| 152| 22.9k| if i < 8 { 153| 12.2k| modules[8][moduleCount - i - 1] = mod 154| 22.9k| } else if i < 9 { 155| 1.53k| modules[8][15 - i - 1 + 1] = mod 156| 22.9k| } else { 157| 21.4k| modules[8][15 - i - 1] = mod 158| 22.9k| } 159| 22.9k| } 160| 1.53k| modules[moduleCount - 8][8] = !test 161| 1.53k| } 162| | 163| 1.53k| private mutating func mapData(_ data: [Int], maskPattern: QRMaskPattern) { 164| 1.53k| var inc = -1 165| 1.53k| var row = moduleCount - 1 166| 1.53k| var bitIndex = 7 167| 1.53k| var byteIndex = 0 168| 1.53k| 169| 1.53k| var col: Int = moduleCount - 1 170| 73.7k| while col > 0 { 171| 72.1k| if col == 6 { 172| 1.53k| col -= 1 173| 72.1k| } 174| 8.61M| while true { 175| 17.2M| for c in 0..<2 { 176| 17.2M| if modules[row][col - c] == nil { 177| 16.0M| var dark = false 178| 16.0M| if byteIndex < data.count { 179| 16.0M| dark = ((UInt(data[byteIndex]) >> bitIndex) & 1) == 1 180| 16.0M| } 181| 16.0M| let mask = maskPattern.getMask(row, col - c) 182| 16.0M| if mask { 183| 7.51M| dark = !dark 184| 16.0M| } 185| 16.0M| modules[row][col - c] = dark 186| 16.0M| bitIndex -= 1 187| 16.0M| if bitIndex == -1 { 188| 2.00M| byteIndex += 1 189| 2.00M| bitIndex = 7 190| 16.0M| } 191| 17.2M| } 192| 17.2M| } 193| 8.61M| row += inc 194| 8.61M| if row < 0 || moduleCount <= row { 195| 72.1k| row -= inc 196| 72.1k| inc = -inc 197| 72.1k| break 198| 8.54M| } 199| 8.54M| } 200| 72.1k| col -= 2 201| 72.1k| } 202| 1.53k| } 203| | 204| | private static let PAD0: UInt = 0xEC 205| | private static let PAD1: UInt = 0x11 206| | 207| | private static func createData( 208| | typeNumber: Int, errorCorrectLevel: QRErrorCorrectLevel, data: QR8bitByte 209| 170| ) throws -> [Int] { 210| 170| let rsBlocks = errorCorrectLevel.getRSBlocksOfType(typeNumber) 211| 170| var buffer = QRBitBuffer() 212| 170| 213| 170| buffer.put(data.mode.rawValue, length: 4) 214| 170| guard let length = data.mode.bitCount(ofType: typeNumber) else { 215| 0| throw AnError("Can't determine length") 216| 170| } 217| 170| buffer.put(UInt(data.count), length: length) 218| 170| data.write(to: &buffer) 219| 170| 220| 170| var totalDataCount = 0 221| 3.47k| for i in rsBlocks.indices { 222| 3.47k| totalDataCount += rsBlocks[i].dataCount 223| 3.47k| } 224| 170| if buffer.bitCount > totalDataCount * 8 { 225| 0| throw AnError("code length overflow. (\(buffer.bitCount)>\(totalDataCount * 8))") 226| 170| } 227| 170| if buffer.bitCount + 4 <= totalDataCount * 8 { 228| 170| buffer.put(0, length: 4) 229| 170| } 230| 170| while buffer.bitCount % 8 != 0 { 231| 0| buffer.put(false) 232| 170| } 233| 247| while true { 234| 247| if buffer.bitCount >= totalDataCount * 8 { 235| 163| break 236| 163| } 237| 84| buffer.put(QRCodeModel.PAD0, length: 8) 238| 84| if buffer.bitCount >= totalDataCount * 8 { 239| 7| break 240| 77| } 241| 77| buffer.put(QRCodeModel.PAD1, length: 8) 242| 170| } 243| 170| guard let bytes = QRCodeModel.createBytes(fromBuffer: buffer, rsBlocks: rsBlocks) else { 244| 0| throw AnError("Unable to construct QRPolynomial") 245| 170| } 246| 170| return bytes 247| 170| } 248| | 249| 170| private static func createBytes(fromBuffer buffer: QRBitBuffer, rsBlocks: [QRRSBlock]) -> [Int]? { 250| 170| var offset = 0 251| 170| var maxDcCount = 0 252| 170| var maxEcCount = 0 253| 170| // Actual contents will be assigned later 254| 170| var dcdata = [[Int]]() 255| 170| dcdata.reserveCapacity(rsBlocks.count) 256| 170| var ecdata = [[Int]]() 257| 170| ecdata.reserveCapacity(rsBlocks.count) 258| 3.47k| for r in rsBlocks.indices { 259| 3.47k| let dcCount = rsBlocks[r].dataCount 260| 3.47k| let ecCount = rsBlocks[r].totalCount - dcCount 261| 3.47k| maxDcCount = max(maxDcCount, dcCount) 262| 3.47k| maxEcCount = max(maxEcCount, ecCount) 263| 3.47k| // Here for `dcdata` 264| 123k| dcdata.append((0..= 0) ? modPoly[modIndex] : 0 278| 99.3k| }) 279| 3.47k| } 280| 170| var totalCodeCount = 0 281| 3.47k| for i in rsBlocks.indices { 282| 3.47k| totalCodeCount += rsBlocks[i].totalCount 283| 3.47k| } 284| 170| var data = [Int](repeating: 0, count: totalCodeCount) 285| 170| var index = 0 286| 7.58k| for i in 0.. QRMaskPattern! { 308| 170| var minLostPoint = 0 309| 170| var pattern = 0 310| 1.36k| for i in 0..<8 { 311| 1.36k| makeImpl(isTest: true, maskPattern: QRMaskPattern(rawValue: i)!) 312| 1.36k| let lostPoint = self.lostPoint 313| 1.36k| if i == 0 || minLostPoint > lostPoint { 314| 555| minLostPoint = lostPoint 315| 555| pattern = i 316| 1.36k| } 317| 1.36k| } 318| 170| return QRMaskPattern(rawValue: pattern) 319| 170| } 320| | 321| 1.36k| var lostPoint: Int { 322| 1.36k| // TODO: Remove if needed 323| 1.36k| // let moduleCount = self.moduleCount 324| 1.36k| var lostPoint = 0 325| 129k| for row in 0.. 5 { 346| 2.10M| lostPoint += (3 + sameCount - 5) 347| 15.4M| } 348| 15.4M| } 349| 129k| } 350| 128k| for row in 0.. 4| | 5| | Permission is hereby granted, free of charge, to any person obtaining a copy 6| | of this software and associated documentation files (the "Software"), to deal 7| | in the Software without restriction, including without limitation the rights 8| | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9| | copies of the Software, and to permit persons to whom the Software is 10| | furnished to do so, subject to the following conditions: 11| | 12| | The above copyright notice and this permission notice shall be included in all 13| | copies or substantial portions of the Software. 14| | 15| | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16| | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17| | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18| | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19| | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20| | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21| | SOFTWARE. 22| | */ 23| | 24| |struct QRCodeType { 25| | static let QRCodeLimitLength: [[Int]] = [ 26| | [17, 14, 11, 7], 27| | [32, 26, 20, 14], 28| | [53, 42, 32, 24], 29| | [78, 62, 46, 34], 30| | [106, 84, 60, 44], 31| | [134, 106, 74, 58], 32| | [154, 122, 86, 64], 33| | [192, 152, 108, 84], 34| | [230, 180, 130, 98], 35| | [271, 213, 151, 119], 36| | [321, 251, 177, 137], 37| | [367, 287, 203, 155], 38| | [425, 331, 241, 177], 39| | [458, 362, 258, 194], 40| | [520, 412, 292, 220], 41| | [586, 450, 322, 250], 42| | [644, 504, 364, 280], 43| | [718, 560, 394, 310], 44| | [792, 624, 442, 338], 45| | [858, 666, 482, 382], 46| | [929, 711, 509, 403], 47| | [1003, 779, 565, 439], 48| | [1091, 857, 611, 461], 49| | [1171, 911, 661, 511], 50| | [1273, 997, 715, 535], 51| | [1367, 1059, 751, 593], 52| | [1465, 1125, 805, 625], 53| | [1528, 1190, 868, 658], 54| | [1628, 1264, 908, 698], 55| | [1732, 1370, 982, 742], 56| | [1840, 1452, 1030, 790], 57| | [1952, 1538, 1112, 842], 58| | [2068, 1628, 1168, 898], 59| | [2188, 1722, 1228, 958], 60| | [2303, 1809, 1283, 983], 61| | [2431, 1911, 1351, 1051], 62| | [2563, 1989, 1423, 1093], 63| | [2699, 2099, 1499, 1139], 64| | [2809, 2213, 1579, 1219], 65| | [2953, 2331, 1663, 1273] 66| | ] 67| |} 68| | 69| |extension QRCodeType { 70| | /// Get the type by string length 71| 174| static func typeNumber(of text: String, errorCorrectLevel: QRErrorCorrectLevel) throws -> Int { 72| 174| let textLength = text.utf8.count 73| 174| let maxTypeNumber = QRCodeLimitLength.count 74| 174| 75| 174| var type = 1 76| 3.49k| for i in 0.. 4| | 5| | Permission is hereby granted, free of charge, to any person obtaining a copy 6| | of this software and associated documentation files (the "Software"), to deal 7| | in the Software without restriction, including without limitation the rights 8| | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9| | copies of the Software, and to permit persons to whom the Software is 10| | furnished to do so, subject to the following conditions: 11| | 12| | The above copyright notice and this permission notice shall be included in all 13| | copies or substantial portions of the Software. 14| | 15| | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16| | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17| | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18| | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19| | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20| | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21| | SOFTWARE. 22| | */ 23| | 24| |/// Error resilience level. 25| |/// 26| |/// - Note: higher the level, larger the size. 27| |/// 28| |/// - Warning: has weird `rawValue`. 29| |public enum QRErrorCorrectLevel: Int, CaseIterable { 30| | /// Error resilience level: 7%. 31| | case L = 1 32| | /// Error resilience level: 15%. 33| | case M = 0 34| | /// Error resilience level: 25%. 35| | case Q = 3 36| | /// Error resilience level: 30%. 37| | case H = 2 38| |} 39| | 40| |#if canImport(CoreImage) 41| |extension QRErrorCorrectLevel { 42| | /// Input value for CIFilter. 43| 0| public var ciQRCodeGeneratorInputCorrectionLevel: String { 44| 0| switch self { 45| 0| case .L: return "l" 46| 0| case .M: return "m" 47| 0| case .Q: return "q" 48| 0| case .H: return "h" 49| 0| } 50| 0| } 51| |} 52| |#endif /Users/travis/build/ApolloZhu/swift_qrcodejs/Sources/QRMaskPattern.swift: 1| |/* 2| | Copyright (c) 2012 davidshimjs 3| | Copyright (c) 2017-2019 ApolloZhu 4| | Copyright (c) 2017 EyreFree 5| | 6| | Permission is hereby granted, free of charge, to any person obtaining a copy 7| | of this software and associated documentation files (the "Software"), to deal 8| | in the Software without restriction, including without limitation the rights 9| | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10| | copies of the Software, and to permit persons to whom the Software is 11| | furnished to do so, subject to the following conditions: 12| | 13| | The above copyright notice and this permission notice shall be included in all 14| | copies or substantial portions of the Software. 15| | 16| | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17| | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18| | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19| | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20| | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21| | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22| | SOFTWARE. 23| | */ 24| | 25| |enum QRMaskPattern: Int { 26| | case _000, _001, _010, _011, _100, _101, _110, _111 27| |} 28| | 29| |extension QRMaskPattern { 30| 16.0M| func getMask(_ i: Int, _ j: Int) -> Bool { 31| 16.0M| switch self { 32| 16.0M| case ._000: 33| 1.79M| return (i + j) % 2 == 0 34| 16.0M| case ._001: 35| 1.80M| return i % 2 == 0 36| 16.0M| case ._010: 37| 1.79M| return j % 3 == 0 38| 16.0M| case ._011: 39| 2.37M| return (i + j) % 3 == 0 40| 16.0M| case ._100: 41| 1.84M| return (i / 2 + j / 3) % 2 == 0 42| 16.0M| case ._101: 43| 1.85M| return (i * j) % 2 + (i * j) % 3 == 0 44| 16.0M| case ._110: 45| 2.55M| return ((i * j) % 2 + (i * j) % 3) % 2 == 0 46| 16.0M| case ._111: 47| 2.03M| return ((i * j) % 3 + (i + j) % 2) % 2 == 0 48| 16.0M| } 49| 16.0M| } 50| |} /Users/travis/build/ApolloZhu/swift_qrcodejs/Sources/QRMath.swift: 1| |/* 2| | Copyright (c) 2012 davidshimjs 3| | Copyright (c) 2017-2019 ApolloZhu 4| | Copyright (c) 2017 EyreFree 5| | 6| | Permission is hereby granted, free of charge, to any person obtaining a copy 7| | of this software and associated documentation files (the "Software"), to deal 8| | in the Software without restriction, including without limitation the rights 9| | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10| | copies of the Software, and to permit persons to whom the Software is 11| | furnished to do so, subject to the following conditions: 12| | 13| | The above copyright notice and this permission notice shall be included in all 14| | copies or substantial portions of the Software. 15| | 16| | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17| | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18| | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19| | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20| | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21| | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22| | SOFTWARE. 23| | */ 24| | 25| |struct QRMath { 26| | 27| | /// glog 28| | /// 29| | /// - Parameter n: n | n >= 1. 30| | /// - Returns: glog(n), or a fatal error if n < 1. 31| 9.82M| static func glog(_ n: Int) -> Int { 32| 9.82M| precondition(n > 0, "glog only works with n > 0, not \(n)") 33| 9.82M| return QRMath.instance.LOG_TABLE[n] 34| 9.82M| } 35| | 36| 6.71M| static func gexp(_ n: Int) -> Int { 37| 6.71M| var n = n 38| 6.71M| while n < 0 { 39| 0| n += 255 40| 6.71M| } 41| 8.81M| while n >= 256 { 42| 2.09M| n -= 255 43| 6.71M| } 44| 6.71M| return QRMath.instance.EXP_TABLE[n] 45| 6.71M| } 46| | 47| | private var EXP_TABLE: [Int] 48| | private var LOG_TABLE: [Int] 49| | 50| | private static let instance = QRMath() 51| 1| private init() { 52| 1| EXP_TABLE = [Int](repeating: 0, count: 256) 53| 1| LOG_TABLE = [Int](repeating: 0, count: 256) 54| 8| for i in 0..<8 { 55| 8| EXP_TABLE[i] = 1 << i 56| 8| } 57| 248| for i in 8..<256 { 58| 248| EXP_TABLE[i] = EXP_TABLE[i - 4] ^ EXP_TABLE[i - 5] ^ EXP_TABLE[i - 6] ^ EXP_TABLE[i - 8] 59| 248| } 60| 255| for i in 0..<255 { 61| 255| LOG_TABLE[EXP_TABLE[i]] = i 62| 255| } 63| 1| } 64| |} /Users/travis/build/ApolloZhu/swift_qrcodejs/Sources/QRMode.swift: 1| |/* 2| | Copyright (c) 2012 davidshimjs 3| | Copyright (c) 2017-2019 ApolloZhu 4| | Copyright (c) 2017 EyreFree 5| | 6| | Permission is hereby granted, free of charge, to any person obtaining a copy 7| | of this software and associated documentation files (the "Software"), to deal 8| | in the Software without restriction, including without limitation the rights 9| | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10| | copies of the Software, and to permit persons to whom the Software is 11| | furnished to do so, subject to the following conditions: 12| | 13| | The above copyright notice and this permission notice shall be included in all 14| | copies or substantial portions of the Software. 15| | 16| | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17| | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18| | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19| | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20| | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21| | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22| | SOFTWARE. 23| | */ 24| | 25| |/// OptionSet 26| |enum QRMode: UInt { 27| | /// 1 << 0 28| | case number = 0b0001 29| | /// 1 << 1 30| | case alphaNumber = 0b0010 31| | /// 1 << 2 32| | case bitByte8 = 0b0100 33| | /// 1 << 3 34| | case kanji = 0b1000 35| |} 36| | 37| |extension QRMode { 38| 170| func bitCount(ofType type: Int) -> Int? { 39| 170| if 1 <= type && type < 10 { 40| 45| switch self { 41| 45| case .number: 42| 0| return 10 43| 45| case .alphaNumber: 44| 0| return 9 45| 45| case .bitByte8, .kanji: 46| 45| return 8 47| 45| } 48| 170| } else if type < 27 { 49| 69| switch self { 50| 69| case .number: 51| 0| return 12 52| 69| case .alphaNumber: 53| 0| return 11 54| 69| case .bitByte8: 55| 69| return 16 56| 69| case .kanji: 57| 0| return 10 58| 69| } 59| 170| } else if type < 41 { 60| 56| switch self { 61| 56| case .number: 62| 0| return 14 63| 56| case .alphaNumber: 64| 0| return 13 65| 56| case .bitByte8: 66| 56| return 16 67| 56| case .kanji: 68| 0| return 12 69| 56| } 70| 170| } else { 71| 114| return nil 72| 114| } 73| 56| } 74| |} /Users/travis/build/ApolloZhu/swift_qrcodejs/Sources/QRPatternLocator.swift: 1| |/* 2| | Copyright (c) 2012 davidshimjs 3| | Copyright (c) 2017-2019 ApolloZhu 4| | 5| | Permission is hereby granted, free of charge, to any person obtaining a copy 6| | of this software and associated documentation files (the "Software"), to deal 7| | in the Software without restriction, including without limitation the rights 8| | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9| | copies of the Software, and to permit persons to whom the Software is 10| | furnished to do so, subject to the following conditions: 11| | 12| | The above copyright notice and this permission notice shall be included in all 13| | copies or substantial portions of the Software. 14| | 15| | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16| | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17| | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18| | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19| | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20| | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21| | SOFTWARE. 22| | */ 23| | 24| |struct QRPatternLocator { 25| | private static let PATTERN_POSITION_TABLE: [[Int]] = [ 26| | [], 27| | [6, 18], 28| | [6, 22], 29| | [6, 26], 30| | [6, 30], 31| | [6, 34], 32| | [6, 22, 38], 33| | [6, 24, 42], 34| | [6, 26, 46], 35| | [6, 28, 50], 36| | [6, 30, 54], 37| | [6, 32, 58], 38| | [6, 34, 62], 39| | [6, 26, 46, 66], 40| | [6, 26, 48, 70], 41| | [6, 26, 50, 74], 42| | [6, 30, 54, 78], 43| | [6, 30, 56, 82], 44| | [6, 30, 58, 86], 45| | [6, 34, 62, 90], 46| | [6, 28, 50, 72, 94], 47| | [6, 26, 50, 74, 98], 48| | [6, 30, 54, 78, 102], 49| | [6, 28, 54, 80, 106], 50| | [6, 32, 58, 84, 110], 51| | [6, 30, 58, 86, 114], 52| | [6, 34, 62, 90, 118], 53| | [6, 26, 50, 74, 98, 122], 54| | [6, 30, 54, 78, 102, 126], 55| | [6, 26, 52, 78, 104, 130], 56| | [6, 30, 56, 82, 108, 134], 57| | [6, 34, 60, 86, 112, 138], 58| | [6, 30, 58, 86, 114, 142], 59| | [6, 34, 62, 90, 118, 146], 60| | [6, 30, 54, 78, 102, 126, 150], 61| | [6, 24, 50, 76, 102, 128, 154], 62| | [6, 28, 54, 80, 106, 132, 158], 63| | [6, 32, 58, 84, 110, 136, 162], 64| | [6, 26, 54, 82, 110, 138, 166], 65| | [6, 30, 58, 86, 114, 142, 170] 66| | ] 67| | 68| 1.53k| static func getPatternPositionOfType(_ typeNumber: Int) -> [Int] { 69| 1.53k| return PATTERN_POSITION_TABLE[typeNumber - 1] 70| 1.53k| } 71| |} /Users/travis/build/ApolloZhu/swift_qrcodejs/Sources/QRPolynomial.swift: 1| |/* 2| | Copyright (c) 2012 davidshimjs 3| | Copyright (c) 2017-2019 ApolloZhu 4| | Copyright (c) 2017 EyreFree 5| | 6| | Permission is hereby granted, free of charge, to any person obtaining a copy 7| | of this software and associated documentation files (the "Software"), to deal 8| | in the Software without restriction, including without limitation the rights 9| | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10| | copies of the Software, and to permit persons to whom the Software is 11| | furnished to do so, subject to the following conditions: 12| | 13| | The above copyright notice and this permission notice shall be included in all 14| | copies or substantial portions of the Software. 15| | 16| | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17| | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18| | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19| | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20| | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21| | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22| | SOFTWARE. 23| | */ 24| | 25| |struct QRPolynomial { 26| | 27| | private var numbers: [Int] 28| | 29| 102k| init!(_ nums: Int..., shift: Int = 0) { 30| 102k| self.init(nums, shift: shift) 31| 102k| } 32| | 33| 328k| init?(_ nums: [Int], shift: Int = 0) { 34| 328k| guard nums.count != 0 else { 35| 0| return nil 36| 328k| } 37| 328k| var offset = 0 38| 452k| while offset < nums.count && nums[offset] == 0 { 39| 123k| offset += 1 40| 328k| } 41| 328k| self.numbers = [Int](repeating: 0, count: nums.count - offset + shift) 42| 9.15M| for i in 0.. Int { 48| 17.2M| return numbers[index] 49| 17.2M| } 50| | 51| 17.2M| subscript(index: Int) -> Int { 52| 17.2M| return get(index: index) 53| 17.2M| } 54| | 55| 2.50M| var count: Int { 56| 2.50M| return numbers.count 57| 2.50M| } 58| | 59| 99.3k| func multiplying(_ e: QRPolynomial) -> QRPolynomial { 60| 99.3k| var nums = [Int](repeating: 0, count: count + e.count - 1) 61| 1.48M| for i in 0.. QRPolynomial { 70| 126k| if count - e.count < 0 { 71| 3.47k| return self 72| 123k| } 73| 123k| let ratio = QRMath.glog(self[0]) - QRMath.glog(e[0]) 74| 123k| var num = [Int](repeating: 0, count: count) 75| 7.37M| for i in 0.. QRPolynomial? { 85| 3.47k| guard var a = QRPolynomial(1) else { return nil } 86| 99.3k| for i in 0.. 4| | 5| | Permission is hereby granted, free of charge, to any person obtaining a copy 6| | of this software and associated documentation files (the "Software"), to deal 7| | in the Software without restriction, including without limitation the rights 8| | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9| | copies of the Software, and to permit persons to whom the Software is 10| | furnished to do so, subject to the following conditions: 11| | 12| | The above copyright notice and this permission notice shall be included in all 13| | copies or substantial portions of the Software. 14| | 15| | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16| | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17| | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18| | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19| | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20| | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21| | SOFTWARE. 22| | */ 23| | 24| |struct QRRSBlock { 25| | let totalCount: Int 26| | let dataCount: Int 27| |} 28| | 29| |extension QRRSBlock { 30| | fileprivate static let RS_BLOCK_TABLE: [[Int]] = [ 31| | [1, 26, 19], 32| | [1, 26, 16], 33| | [1, 26, 13], 34| | [1, 26, 9], 35| | [1, 44, 34], 36| | [1, 44, 28], 37| | [1, 44, 22], 38| | [1, 44, 16], 39| | [1, 70, 55], 40| | [1, 70, 44], 41| | [2, 35, 17], 42| | [2, 35, 13], 43| | [1, 100, 80], 44| | [2, 50, 32], 45| | [2, 50, 24], 46| | [4, 25, 9], 47| | [1, 134, 108], 48| | [2, 67, 43], 49| | [2, 33, 15, 2, 34, 16], 50| | [2, 33, 11, 2, 34, 12], 51| | [2, 86, 68], 52| | [4, 43, 27], 53| | [4, 43, 19], 54| | [4, 43, 15], 55| | [2, 98, 78], 56| | [4, 49, 31], 57| | [2, 32, 14, 4, 33, 15], 58| | [4, 39, 13, 1, 40, 14], 59| | [2, 121, 97], 60| | [2, 60, 38, 2, 61, 39], 61| | [4, 40, 18, 2, 41, 19], 62| | [4, 40, 14, 2, 41, 15], 63| | [2, 146, 116], 64| | [3, 58, 36, 2, 59, 37], 65| | [4, 36, 16, 4, 37, 17], 66| | [4, 36, 12, 4, 37, 13], 67| | [2, 86, 68, 2, 87, 69], 68| | [4, 69, 43, 1, 70, 44], 69| | [6, 43, 19, 2, 44, 20], 70| | [6, 43, 15, 2, 44, 16], 71| | [4, 101, 81], 72| | [1, 80, 50, 4, 81, 51], 73| | [4, 50, 22, 4, 51, 23], 74| | [3, 36, 12, 8, 37, 13], 75| | [2, 116, 92, 2, 117, 93], 76| | [6, 58, 36, 2, 59, 37], 77| | [4, 46, 20, 6, 47, 21], 78| | [7, 42, 14, 4, 43, 15], 79| | [4, 133, 107], 80| | [8, 59, 37, 1, 60, 38], 81| | [8, 44, 20, 4, 45, 21], 82| | [12, 33, 11, 4, 34, 12], 83| | [3, 145, 115, 1, 146, 116], 84| | [4, 64, 40, 5, 65, 41], 85| | [11, 36, 16, 5, 37, 17], 86| | [11, 36, 12, 5, 37, 13], 87| | [5, 109, 87, 1, 110, 88], 88| | [5, 65, 41, 5, 66, 42], 89| | [5, 54, 24, 7, 55, 25], 90| | [11, 36, 12, 7, 37, 13], 91| | [5, 122, 98, 1, 123, 99], 92| | [7, 73, 45, 3, 74, 46], 93| | [15, 43, 19, 2, 44, 20], 94| | [3, 45, 15, 13, 46, 16], 95| | [1, 135, 107, 5, 136, 108], 96| | [10, 74, 46, 1, 75, 47], 97| | [1, 50, 22, 15, 51, 23], 98| | [2, 42, 14, 17, 43, 15], 99| | [5, 150, 120, 1, 151, 121], 100| | [9, 69, 43, 4, 70, 44], 101| | [17, 50, 22, 1, 51, 23], 102| | [2, 42, 14, 19, 43, 15], 103| | [3, 141, 113, 4, 142, 114], 104| | [3, 70, 44, 11, 71, 45], 105| | [17, 47, 21, 4, 48, 22], 106| | [9, 39, 13, 16, 40, 14], 107| | [3, 135, 107, 5, 136, 108], 108| | [3, 67, 41, 13, 68, 42], 109| | [15, 54, 24, 5, 55, 25], 110| | [15, 43, 15, 10, 44, 16], 111| | [4, 144, 116, 4, 145, 117], 112| | [17, 68, 42], 113| | [17, 50, 22, 6, 51, 23], 114| | [19, 46, 16, 6, 47, 17], 115| | [2, 139, 111, 7, 140, 112], 116| | [17, 74, 46], 117| | [7, 54, 24, 16, 55, 25], 118| | [34, 37, 13], 119| | [4, 151, 121, 5, 152, 122], 120| | [4, 75, 47, 14, 76, 48], 121| | [11, 54, 24, 14, 55, 25], 122| | [16, 45, 15, 14, 46, 16], 123| | [6, 147, 117, 4, 148, 118], 124| | [6, 73, 45, 14, 74, 46], 125| | [11, 54, 24, 16, 55, 25], 126| | [30, 46, 16, 2, 47, 17], 127| | [8, 132, 106, 4, 133, 107], 128| | [8, 75, 47, 13, 76, 48], 129| | [7, 54, 24, 22, 55, 25], 130| | [22, 45, 15, 13, 46, 16], 131| | [10, 142, 114, 2, 143, 115], 132| | [19, 74, 46, 4, 75, 47], 133| | [28, 50, 22, 6, 51, 23], 134| | [33, 46, 16, 4, 47, 17], 135| | [8, 152, 122, 4, 153, 123], 136| | [22, 73, 45, 3, 74, 46], 137| | [8, 53, 23, 26, 54, 24], 138| | [12, 45, 15, 28, 46, 16], 139| | [3, 147, 117, 10, 148, 118], 140| | [3, 73, 45, 23, 74, 46], 141| | [4, 54, 24, 31, 55, 25], 142| | [11, 45, 15, 31, 46, 16], 143| | [7, 146, 116, 7, 147, 117], 144| | [21, 73, 45, 7, 74, 46], 145| | [1, 53, 23, 37, 54, 24], 146| | [19, 45, 15, 26, 46, 16], 147| | [5, 145, 115, 10, 146, 116], 148| | [19, 75, 47, 10, 76, 48], 149| | [15, 54, 24, 25, 55, 25], 150| | [23, 45, 15, 25, 46, 16], 151| | [13, 145, 115, 3, 146, 116], 152| | [2, 74, 46, 29, 75, 47], 153| | [42, 54, 24, 1, 55, 25], 154| | [23, 45, 15, 28, 46, 16], 155| | [17, 145, 115], 156| | [10, 74, 46, 23, 75, 47], 157| | [10, 54, 24, 35, 55, 25], 158| | [19, 45, 15, 35, 46, 16], 159| | [17, 145, 115, 1, 146, 116], 160| | [14, 74, 46, 21, 75, 47], 161| | [29, 54, 24, 19, 55, 25], 162| | [11, 45, 15, 46, 46, 16], 163| | [13, 145, 115, 6, 146, 116], 164| | [14, 74, 46, 23, 75, 47], 165| | [44, 54, 24, 7, 55, 25], 166| | [59, 46, 16, 1, 47, 17], 167| | [12, 151, 121, 7, 152, 122], 168| | [12, 75, 47, 26, 76, 48], 169| | [39, 54, 24, 14, 55, 25], 170| | [22, 45, 15, 41, 46, 16], 171| | [6, 151, 121, 14, 152, 122], 172| | [6, 75, 47, 34, 76, 48], 173| | [46, 54, 24, 10, 55, 25], 174| | [2, 45, 15, 64, 46, 16], 175| | [17, 152, 122, 4, 153, 123], 176| | [29, 74, 46, 14, 75, 47], 177| | [49, 54, 24, 10, 55, 25], 178| | [24, 45, 15, 46, 46, 16], 179| | [4, 152, 122, 18, 153, 123], 180| | [13, 74, 46, 32, 75, 47], 181| | [48, 54, 24, 14, 55, 25], 182| | [42, 45, 15, 32, 46, 16], 183| | [20, 147, 117, 4, 148, 118], 184| | [40, 75, 47, 7, 76, 48], 185| | [43, 54, 24, 22, 55, 25], 186| | [10, 45, 15, 67, 46, 16], 187| | [19, 148, 118, 6, 149, 119], 188| | [18, 75, 47, 31, 76, 48], 189| | [34, 54, 24, 34, 55, 25], 190| | [20, 45, 15, 61, 46, 16] 191| | ] 192| |} 193| | 194| |extension QRErrorCorrectLevel { 195| 170| func getRSBlocksOfType(_ typeNumber: Int) -> [QRRSBlock] { 196| 170| let rsBlock = getRsBlockTableOfType(typeNumber) 197| 170| let length = rsBlock.count / 3 198| 170| 199| 301| return (0.. [QRRSBlock] in 200| 301| let count = rsBlock[i * 3 + 0] 201| 301| let totalCount = rsBlock[i * 3 + 1] 202| 301| let dataCount = rsBlock[i * 3 + 2] 203| 301| let block = QRRSBlock(totalCount: totalCount, dataCount: dataCount) 204| 301| return [QRRSBlock](repeating: block, count: count) 205| 301| } 206| 170| } 207| | 208| 170| private func getRsBlockTableOfType(_ typeNumber: Int) -> [Int] { 209| 170| switch self { 210| 170| case .L: 211| 43| return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0] 212| 170| case .M: 213| 42| return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1] 214| 170| case .Q: 215| 41| return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2] 216| 170| case .H: 217| 44| return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3] 218| 170| } 219| 170| } 220| |} <<<<<< EOF # path=fixes ./Example/main.swift:3,10,13,22,34 ./Tests/LinuxMain.swift:3 ./Tests/swift_qrcodejsTests/swift_qrcodejsTests.swift:3,10,13,22,25,30,31,36,37,38,45,46,48,49,55,93,95,96,102,140,142,143,182,183,184,189,227,229,230,235,257,259,260,266,388,390,391,399,400,401,410,411,412,413,421 ./Carthage/Build/watchOS/swift_qrcodejs.framework/Headers/swift_qrcodejs.h:3,5,12,15,24,40,47,50,53 ./Carthage/Build/watchOS/swift_qrcodejs.framework/Headers/swift_qrcodejs-Swift.h:8,21,25,31,53,68,117,122,126,174,182,189,194,201,214,218,224,246,261,310,315,319,367,375,382,387,392,405,409,415,437,452,501,506,510,558,566,573,578,580 ./Carthage/Build/iOS/swift_qrcodejs.framework/Headers/swift_qrcodejs.h:3,5,12,15,24,40,47,50,53 ./Carthage/Build/iOS/swift_qrcodejs.framework/Headers/swift_qrcodejs-Swift.h:10,23,27,33,55,70,119,124,128,176,184,191,196,201,214,218,224,246,261,310,315,319,367,375,382,387,389,396,409,413,419,441,456,505,510,514,562,570,577,582,587,600,604,610,632,647,696,701,705,753,761,768,773,775 ./Carthage/Build/Mac/swift_qrcodejs.framework/Versions/A/Headers/swift_qrcodejs.h:3,5,12,15,24,40,47,50,53 ./Carthage/Build/Mac/swift_qrcodejs.framework/Versions/A/Headers/swift_qrcodejs-Swift.h:4,17,21,27,49,64,113,118,122,170,178,185 ./Carthage/Build/tvOS/swift_qrcodejs.framework/Headers/swift_qrcodejs.h:3,5,12,15,24,40,47,50,53 ./Carthage/Build/tvOS/swift_qrcodejs.framework/Headers/swift_qrcodejs-Swift.h:8,21,25,31,53,68,117,122,126,174,182,189,194,199,212,216,222,244,259,308,313,317,365,373,380,385 ./Package.swift:3,5 ./Sources/QRMode.swift:5,12,15,24,35,36,47,58,69,72,73,74 ./Sources/QRCodeModel.swift:5,12,15,24,32,34,37,38,47,50,51,55,56,59,60,72,74,75,80,84,91,92,93,94,95,100,103,104,105,106,115,122,123,124,125,126,127,128,135,136,137,143,150,151,158,159,161,162,168,173,180,184,190,191,192,198,199,201,202,203,206,212,216,219,223,226,229,232,236,240,242,245,247,248,271,279,283,291,292,293,299,300,301,303,304,305,316,317,319,320,332,336,339,342,343,344,347,348,349,355,358,361,364,367,368,369,380,389,390,391,397,398,399,403,404 ./Sources/QRMath.swift:5,12,15,24,26,34,35,40,43,45,46,49,56,59,62,63,64 ./Sources/AnError.swift:3,10,13,22,27,28 ./Sources/QR8bitByte.swift:5,12,15,24,26,30,34,36,37,40,41,45,46,47 ./Sources/QRBitBuffer.swift:4,11,14,23,27,31,32,35,36,40,41,42,47,50,52,53 ./Sources/QRPolynomial.swift:5,12,15,24,26,28,31,32,36,40,44,45,46,49,50,53,54,57,58,64,65,67,68,72,77,80,82,83,88,90,91 ./Sources/QRCodeType.swift:4,11,14,23,67,68,74,78,88,89,94,95,97,98 ./Sources/swift_qrcodejs.h:3,5,12,15,24,40,47,50,53 ./Sources/QRErrorCorrectLevel.swift:4,11,14,23,38,39,49,50,51 ./Sources/QRMaskPattern.swift:5,12,15,24,27,28,48,49,50 ./Sources/QRCode.swift:3,10,13,22,23,34,56,57,71,72,73,75,87,88 ./Sources/QRRSBlock.swift:4,11,14,23,27,28,192,193,198,205,206,207,218,219,220 ./Sources/BCHUtil.swift:4,11,14,23,30,35,37,38,43,45,46,53,55,56 ./Sources/QRPatternLocator.swift:4,11,14,23,67,70,71 <<<<<< EOF