Merge lp:~jose-exposito89/ubuntuone-ios-files/social-networking into lp:ubuntuone-ios-files

Proposed by Paul Hummer
Status: Work in progress
Proposed branch: lp:~jose-exposito89/ubuntuone-ios-files/social-networking
Merge into: lp:ubuntuone-ios-files
Diff against target: 167361 lines (+155508/-8083)
559 files modified
Dependencies/JSONKit/CHANGELOG.md (+0/-389)
Dependencies/JSONKit/JSONKit.h (+0/-251)
Dependencies/JSONKit/JSONKit.m (+0/-3022)
Dependencies/JSONKit/README.md (+0/-307)
Dependencies/Reachability/Reachability.h (+0/-88)
Dependencies/Reachability/Reachability.m (+0/-274)
Dependencies/ShareKit/.gitignore (+12/-0)
Dependencies/ShareKit/.gitmodules (+15/-0)
Dependencies/ShareKit/Classes/Example/ExampleShareFile.h (+38/-0)
Dependencies/ShareKit/Classes/Example/ExampleShareFile.m (+84/-0)
Dependencies/ShareKit/Classes/Example/ExampleShareImage.h (+38/-0)
Dependencies/ShareKit/Classes/Example/ExampleShareImage.m (+89/-0)
Dependencies/ShareKit/Classes/Example/ExampleShareLink.h (+38/-0)
Dependencies/ShareKit/Classes/Example/ExampleShareLink.m (+90/-0)
Dependencies/ShareKit/Classes/Example/ExampleShareText.h (+38/-0)
Dependencies/ShareKit/Classes/Example/ExampleShareText.m (+90/-0)
Dependencies/ShareKit/Classes/Example/RootViewController.h (+14/-0)
Dependencies/ShareKit/Classes/Example/RootViewController.m (+139/-0)
Dependencies/ShareKit/Classes/Example/ShareKitAppDelegate.h (+21/-0)
Dependencies/ShareKit/Classes/Example/ShareKitAppDelegate.m (+88/-0)
Dependencies/ShareKit/Classes/Example/ShareKitDemoConfigurator.h (+13/-0)
Dependencies/ShareKit/Classes/Example/ShareKitDemoConfigurator.m (+214/-0)
Dependencies/ShareKit/Classes/ShareKit/Configuration/DefaultSHKConfigurator.h (+115/-0)
Dependencies/ShareKit/Classes/ShareKit/Configuration/DefaultSHKConfigurator.m (+410/-0)
Dependencies/ShareKit/Classes/ShareKit/Configuration/SHKConfiguration.h (+41/-0)
Dependencies/ShareKit/Classes/ShareKit/Configuration/SHKConfiguration.m (+138/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Base Sharer Classes/SHKOAuthSharer.h (+91/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Base Sharer Classes/SHKOAuthSharer.m (+346/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Base Sharer Classes/SHKSharer.h (+209/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Base Sharer Classes/SHKSharer.m (+829/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Base Sharer Classes/SHKSharerDelegate.h (+14/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Base Sharer Classes/SHKSharerDelegate.m (+82/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Categories/GTMNSString+HTML.h (+66/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Categories/GTMNSString+HTML.m (+521/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Categories/NSData+md5.h (+3/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Categories/NSData+md5.m (+22/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Categories/NSHTTPCookieStorage+DeleteForURL.h (+15/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Categories/NSHTTPCookieStorage+DeleteForURL.m (+23/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Categories/NSMutableDictionary+NSNullsToEmptyStrings.h (+15/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Categories/NSMutableDictionary+NSNullsToEmptyStrings.m (+29/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Categories/UIWebView+SHK.h (+38/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Categories/UIWebView+SHK.m (+37/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/Categories/NSMutableURLRequest+Parameters.h (+35/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/Categories/NSMutableURLRequest+Parameters.m (+108/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/Categories/NSString+URLEncoding.h (+34/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/Categories/NSString+URLEncoding.m (+52/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/Categories/NSURL+Base.h (+34/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/Categories/NSURL+Base.m (+38/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/Crypto/Base64Transcoder.c (+230/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/Crypto/Base64Transcoder.h (+36/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/Crypto/hmac.c (+88/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/Crypto/hmac.h (+31/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/Crypto/sha1.c (+174/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/Crypto/sha1.h (+12/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/OAAsynchronousDataFetcher.h (+45/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/OAAsynchronousDataFetcher.m (+141/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/OAConsumer.h (+40/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/OAConsumer.m (+51/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/OADataFetcher.h (+44/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/OADataFetcher.m (+67/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/OAHMAC_SHA1SignatureProvider.h (+32/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/OAHMAC_SHA1SignatureProvider.m (+58/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/OAMutableURLRequest.h (+69/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/OAMutableURLRequest.m (+250/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/OAPlaintextSignatureProvider.h (+31/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/OAPlaintextSignatureProvider.m (+43/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/OARequestParameter.h (+45/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/OARequestParameter.m (+70/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/OAServiceTicket.h (+47/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/OAServiceTicket.m (+59/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/OASignatureProviding.h (+34/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/OAToken.h (+43/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/OAToken.m (+109/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/OAuth/OAuthConsumer.h (+39/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/SHKRequest.h (+74/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/SHKRequest.m (+162/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/SHKXMLResponseParser.h (+15/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/Helpers/SHKXMLResponseParser.m (+132/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/SHK.h (+131/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/SHK.m (+832/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/SHKItem.h (+153/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/SHKItem.m (+376/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/SHKOfflineSharer.h (+56/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/SHKOfflineSharer.m (+172/-0)
Dependencies/ShareKit/Classes/ShareKit/Core/SHKSharers.plist (+36/-0)
Dependencies/ShareKit/Classes/ShareKit/Customize UI/SHKCustomFormControllerLargeTextField.h (+35/-0)
Dependencies/ShareKit/Classes/ShareKit/Customize UI/SHKCustomFormControllerLargeTextField.m (+35/-0)
Dependencies/ShareKit/Classes/ShareKit/Customize UI/SHKCustomFormFieldCell.h (+36/-0)
Dependencies/ShareKit/Classes/ShareKit/Customize UI/SHKCustomFormFieldCell.m (+35/-0)
Dependencies/ShareKit/Classes/ShareKit/Reachability/Reachability.h (+89/-0)
Dependencies/ShareKit/Classes/ShareKit/Reachability/Reachability.m (+273/-0)
Dependencies/ShareKit/Classes/ShareKit/ShareKit.bundle/ca.lproj/Localizable.strings (+207/-0)
Dependencies/ShareKit/Classes/ShareKit/ShareKit.bundle/cs.lproj/Localizable.strings (+212/-0)
Dependencies/ShareKit/Classes/ShareKit/ShareKit.bundle/de.lproj/Localizable.strings (+96/-0)
Dependencies/ShareKit/Classes/ShareKit/ShareKit.bundle/en.lproj/Localizable.strings (+207/-0)
Dependencies/ShareKit/Classes/ShareKit/ShareKit.bundle/eu.lproj/Localizable.strings (+89/-0)
Dependencies/ShareKit/Classes/ShareKit/ShareKit.bundle/fi.lproj/Localizable.strings (+106/-0)
Dependencies/ShareKit/Classes/ShareKit/ShareKit.bundle/fr.lproj/Localizable.strings (+94/-0)
Dependencies/ShareKit/Classes/ShareKit/ShareKit.bundle/it.lproj/Localizable.strings (+89/-0)
Dependencies/ShareKit/Classes/ShareKit/ShareKit.bundle/ja.lproj/Localizable.strings (+108/-0)
Dependencies/ShareKit/Classes/ShareKit/ShareKit.bundle/ko.lproj/Localizable.strings (+107/-0)
Dependencies/ShareKit/Classes/ShareKit/ShareKit.bundle/nl.lproj/Localizable.strings (+89/-0)
Dependencies/ShareKit/Classes/ShareKit/ShareKit.bundle/no.lproj/Localizable.strings (+89/-0)
Dependencies/ShareKit/Classes/ShareKit/ShareKit.bundle/pl.lproj/Localizable.strings (+96/-0)
Dependencies/ShareKit/Classes/ShareKit/ShareKit.bundle/pt.lproj/Localizable.strings (+207/-0)
Dependencies/ShareKit/Classes/ShareKit/ShareKit.bundle/ru.lproj/Localizable.strings (+91/-0)
Dependencies/ShareKit/Classes/ShareKit/ShareKit.bundle/sk.lproj/Localizable.strings (+213/-0)
Dependencies/ShareKit/Classes/ShareKit/ShareKit.bundle/zh_CN.lproj/Localizable.strings (+161/-0)
Dependencies/ShareKit/Classes/ShareKit/ShareKit.bundle/zh_TW.lproj/Localizable.strings (+131/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Actions/Copy/SHKCopy.h (+36/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Actions/Copy/SHKCopy.m (+102/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Actions/Email/SHKMail.h (+45/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Actions/Email/SHKMail.m (+213/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Actions/Logout of All Services/SHKLogout.h (+36/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Actions/Logout of All Services/SHKLogout.m (+99/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Actions/Open in Safari/SHKSafari.h (+36/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Actions/Open in Safari/SHKSafari.m (+83/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Actions/Print/SHKPrint.h (+8/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Actions/Print/SHKPrint.m (+98/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Actions/Save to Album/SHKPhotoAlbum.h (+36/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Actions/Save to Album/SHKPhotoAlbum.m (+89/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Actions/Text Message/SHKTextMessage.h (+39/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Actions/Text Message/SHKTextMessage.m (+173/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Delicious/SHKDelicious.h (+35/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Delicious/SHKDelicious.m (+191/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Diigo/SHKDiigo.h (+35/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Diigo/SHKDiigo.m (+187/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Evernote/SHKEvernote.h (+28/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Evernote/SHKEvernote.m (+257/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Evernote/SHKEvernote.md (+71/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Facebook/SHKFacebook.h (+37/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Facebook/SHKFacebook.m (+485/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Flickr/SHKFlickr.h (+52/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Flickr/SHKFlickr.m (+404/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/FoursquareV2/NSError+SHKFoursquareV2.h (+40/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/FoursquareV2/NSError+SHKFoursquareV2.m (+70/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/FoursquareV2/SHKFoursquareV2.h (+68/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/FoursquareV2/SHKFoursquareV2.m (+264/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/FoursquareV2/SHKFoursquareV2CheckInForm.h (+34/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/FoursquareV2/SHKFoursquareV2CheckInForm.m (+42/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/FoursquareV2/SHKFoursquareV2OAuthView.h (+32/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/FoursquareV2/SHKFoursquareV2OAuthView.m (+61/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/FoursquareV2/SHKFoursquareV2Request.h (+51/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/FoursquareV2/SHKFoursquareV2Request.m (+152/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/FoursquareV2/SHKFoursquareV2Venue.h (+44/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/FoursquareV2/SHKFoursquareV2Venue.m (+73/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/FoursquareV2/SHKFoursquareV2VenuesForm.h (+64/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/FoursquareV2/SHKFoursquareV2VenuesForm.m (+411/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Google Reader/SHKGoogleReader.h (+42/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Google Reader/SHKGoogleReader.m (+358/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Instagram/SHKInstagram.h (+32/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Instagram/SHKInstagram.m (+176/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Instapaper/SHKInstapaper.h (+34/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Instapaper/SHKInstapaper.m (+174/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Kippt/SHKKippt.h (+42/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Kippt/SHKKippt.m (+317/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/LinkedIn/SHKLinkedIn.h (+34/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/LinkedIn/SHKLinkedIn.m (+320/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Pinboard/SHKPinboard.h (+36/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Pinboard/SHKPinboard.m (+190/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Read It Later/SHKReadItLater.h (+35/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Read It Later/SHKReadItLater.m (+204/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Readability/SHKReadability.h (+44/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Readability/SHKReadability.m (+309/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Tumblr/SHKTumblr.h (+18/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Tumblr/SHKTumblr.m (+422/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Twitter/SHKTwitter.h (+60/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Twitter/SHKTwitter.m (+741/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Twitter/SHKiOS5Twitter.h (+14/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Twitter/SHKiOS5Twitter.m (+117/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Vkontakte/SHKVkontakte.h (+47/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Vkontakte/SHKVkontakte.m (+442/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Vkontakte/SHKVkontakteOAuthView.h (+44/-0)
Dependencies/ShareKit/Classes/ShareKit/Sharers/Services/Vkontakte/SHKVkontakteOAuthView.m (+162/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKActionSheet.h (+47/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKActionSheet.m (+126/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKActivityIndicator.h (+61/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKActivityIndicator.m (+318/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKFormController.h (+64/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKFormController.m (+294/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKFormControllerLargeTextField.h (+33/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKFormControllerLargeTextField.m (+272/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKFormFieldCell.h (+51/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKFormFieldCell.m (+63/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKFormFieldCellOptionPicker.h (+13/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKFormFieldCellOptionPicker.m (+30/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKFormFieldCellSwitch.h (+15/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKFormFieldCellSwitch.m (+57/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKFormFieldCellText.h (+15/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKFormFieldCellText.m (+94/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKFormFieldCell_PrivateProperties.h (+15/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKFormFieldSettings.h (+76/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKFormFieldSettings.m (+79/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKFormOptionController.h (+52/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKFormOptionController.m (+238/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKOAuthView.h (+58/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKOAuthView.m (+166/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKShareItemDelegate.h (+45/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKShareMenu.h (+62/-0)
Dependencies/ShareKit/Classes/ShareKit/UI/SHKShareMenu.m (+368/-0)
Dependencies/ShareKit/MainWindow.xib (+279/-0)
Dependencies/ShareKit/README.md (+22/-0)
Dependencies/ShareKit/Resources-iPad/MainWindow-iPad.xib (+304/-0)
Dependencies/ShareKit/RootViewController.xib (+384/-0)
Dependencies/ShareKit/ShareKit-Info.plist (+46/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/project.pbxproj (+6126/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Copy.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Delicious.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Demo App.xcscheme (+86/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Diigo.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Email.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Evernote SDK.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Evernote.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Facebook SDK.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Facebook.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Flickr SDK.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Flickr.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/FoursquareV2.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Google Reader.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Instagram.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Instapaper.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/JSONKit.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Kippt.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/LinkedIn.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Logout.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/OAuth.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Open in Safari.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Pinboard.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Print.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Reachability.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Read It Later.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Readability.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Resource Bundle.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/SSKeyChain.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Save to Album.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Static Library Core.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Static Library.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Text Message.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Tumblr.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/Twitter.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/VKontakte.xcscheme (+59/-0)
Dependencies/ShareKit/ShareKit.xcodeproj/xcuserdata/jose.xcuserdatad/xcschemes/xcschememanagement.plist (+362/-0)
Dependencies/ShareKit/ShareKitLibrary/ShareKitLibrary-Prefix.pch (+8/-0)
Dependencies/ShareKit/ShareKitLibraryResources/ShareKitLibraryResources-Info.plist (+46/-0)
Dependencies/ShareKit/ShareKit_Prefix.pch (+14/-0)
Dependencies/ShareKit/Submodules/JSONKit/.git (+1/-0)
Dependencies/ShareKit/Submodules/JSONKit/CHANGELOG.md (+389/-0)
Dependencies/ShareKit/Submodules/JSONKit/JSONKit.h (+251/-0)
Dependencies/ShareKit/Submodules/JSONKit/JSONKit.m (+3065/-0)
Dependencies/ShareKit/Submodules/JSONKit/README.md (+310/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/.git (+1/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/.gitignore (+1/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/APACHE-LICENSE-2.0.txt (+202/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/CHANGES.md (+46/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/LICENSE (+27/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/NOTICE (+5/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/README.md (+109/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/SampleApp/AppDelegate.h (+14/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/SampleApp/AppDelegate.m (+75/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/SampleApp/SampleApp-Info.plist (+42/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/SampleApp/SampleApp-Prefix.pch (+14/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/SampleApp/en.lproj/InfoPlist.strings (+2/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/SampleApp/en.lproj/iPad.storyboard (+130/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/SampleApp/en.lproj/iPhone.storyboard (+109/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/SampleApp/iPadViewController.h (+22/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/SampleApp/iPadViewController.m (+153/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/SampleApp/iPhoneViewController.h (+19/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/SampleApp/iPhoneViewController.m (+115/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/SampleApp/main.m (+18/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/UnitTests/3rdParty/OCMock/LICENSE (+15/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/UnitTests/3rdParty/OCMock/OCMock/NSNotificationCenter+OCMAdditions.h (+15/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/UnitTests/3rdParty/OCMock/OCMock/OCMArg.h (+33/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/UnitTests/3rdParty/OCMock/OCMock/OCMConstraint.h (+64/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/UnitTests/3rdParty/OCMock/OCMock/OCMock.h (+10/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/UnitTests/3rdParty/OCMock/OCMock/OCMockObject.h (+43/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/UnitTests/3rdParty/OCMock/OCMock/OCMockRecorder.h (+32/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/UnitTests/EvernoteSessionTests.h (+13/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/UnitTests/EvernoteSessionTests.m (+267/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/UnitTests/UnitTests-Info.plist (+22/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/UnitTests/UnitTests-Prefix.pch (+8/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/UnitTests/en.lproj/InfoPlist.strings (+2/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios.xcodeproj/project.pbxproj (+983/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios.xcodeproj/project.xcworkspace/contents.xcworkspacedata (+7/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/NSString+URLEncoding/LICENSE (+19/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/NSString+URLEncoding/NSString+URLEncoding.h (+34/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/NSString+URLEncoding/NSString+URLEncoding.m (+52/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/SSKeychain/LICENSE (+20/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/SSKeychain/SSKeychain.h (+289/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/SSKeychain/SSKeychain.m (+175/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/Thrift/LICENSE (+177/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/Thrift/TApplicationException.h (+46/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/Thrift/TApplicationException.m (+130/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/Thrift/TException.h (+34/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/Thrift/TException.m (+64/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/Thrift/TProcessor.h (+29/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/Thrift/TProcessorFactory.h (+27/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/Thrift/Thrift.h (+11/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/Thrift/protocol/TBinaryProtocol.h (+51/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/Thrift/protocol/TBinaryProtocol.m (+477/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/Thrift/protocol/TProtocol.h (+148/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/Thrift/protocol/TProtocolException.h (+25/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/Thrift/protocol/TProtocolException.m (+23/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/Thrift/protocol/TProtocolFactory.h (+29/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/Thrift/protocol/TProtocolUtil.h (+29/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/Thrift/protocol/TProtocolUtil.m (+104/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/Thrift/transport/THTTPClient.h (+42/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/Thrift/transport/THTTPClient.m (+160/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/Thrift/transport/TMemoryBuffer.h (+29/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/Thrift/transport/TMemoryBuffer.m (+71/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/Thrift/transport/TTransport.h (+36/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/Thrift/transport/TTransportException.h (+30/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/Thrift/transport/TTransportException.m (+43/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/cocoa-oauth/GCOAuth.h (+145/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/cocoa-oauth/GCOAuth.m (+330/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/cocoa-oauth/LICENSE (+26/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/cocoa-oauth/NSData+Base64.h (+42/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/3rdParty/cocoa-oauth/NSData+Base64.m (+313/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/EDAM/EDAM.h (+5/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/EDAM/EDAMErrors.h (+127/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/EDAM/EDAMErrors.m (+506/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/EDAM/EDAMLimits.h (+130/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/EDAM/EDAMLimits.m (+476/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/EDAM/EDAMNoteStore.h (+1088/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/EDAM/EDAMNoteStore.m (+51269/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/EDAM/EDAMTypes.h (+1524/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/EDAM/EDAMTypes.m (+9291/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/EDAM/EDAMUserStore.h (+423/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/EDAM/EDAMUserStore.m (+6065/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/EvernoteNoteStore.h (+316/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/EvernoteNoteStore.m (+769/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/EvernoteSDK.h (+42/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/EvernoteSDK.m (+32/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/EvernoteSession.h (+111/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/EvernoteSession.m (+559/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/EvernoteUserStore.h (+60/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/EvernoteUserStore.m (+104/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/evernote-sdk-ios-Prefix.pch (+7/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/internal/ENAPI.h (+60/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/internal/ENAPI.m (+205/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/internal/ENCredentialStore.h (+62/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/internal/ENCredentialStore.m (+142/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/internal/ENCredentials.h (+49/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/internal/ENCredentials.m (+121/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/internal/ENOAuthViewController.h (+27/-0)
Dependencies/ShareKit/Submodules/evernote-ios-sdk/evernote-sdk-ios/internal/ENOAuthViewController.m (+115/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/.arcconfig (+5/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/.git (+1/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/.gitignore (+26/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/README.mdown (+55/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/sample/Hackbook/Hackbook.xcodeproj/project.pbxproj (+440/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/sample/Hackbook/Hackbook/APICallsViewController.h (+82/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/sample/Hackbook/Hackbook/APICallsViewController.m (+1269/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/sample/Hackbook/Hackbook/APIResultsViewController.h (+37/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/sample/Hackbook/Hackbook/APIResultsViewController.m (+305/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/sample/Hackbook/Hackbook/DataSet.h (+25/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/sample/Hackbook/Hackbook/DataSet.m (+244/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/sample/Hackbook/Hackbook/Hackbook-Info.plist (+49/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/sample/Hackbook/Hackbook/Hackbook-Prefix.pch (+14/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/sample/Hackbook/Hackbook/HackbookAppDelegate.h (+37/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/sample/Hackbook/Hackbook/HackbookAppDelegate.m (+157/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/sample/Hackbook/Hackbook/RootViewController.h (+51/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/sample/Hackbook/Hackbook/RootViewController.m (+453/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/sample/Hackbook/Hackbook/en.lproj/InfoPlist.strings (+2/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/sample/Hackbook/Hackbook/en.lproj/MainWindow.xib (+220/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/sample/Hackbook/Hackbook/iPad/en.lproj/MainWindow-iPad.xib (+206/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/sample/Hackbook/Hackbook/main.m (+24/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/sample/Hackbook/ReadMe.txt (+37/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/scripts/build_facebook_ios_sdk_static_lib.sh (+91/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/FBConnect.h (+22/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/FBDialog.h (+165/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/FBDialog.m (+688/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/FBFrictionlessRequestSettings.h (+74/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/FBFrictionlessRequestSettings.m (+162/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/FBLoginDialog.h (+48/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/FBLoginDialog.m (+94/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/FBRequest.h (+142/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/FBRequest.m (+381/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/Facebook.h (+153/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/Facebook.m (+848/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/JSON/JSON.h (+50/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/JSON/NSObject+SBJSON.h (+68/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/JSON/NSObject+SBJSON.m (+53/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/JSON/NSString+SBJSON.h (+58/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/JSON/NSString+SBJSON.m (+55/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/JSON/SBJSON.h (+75/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/JSON/SBJSON.m (+212/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/JSON/SBJsonBase.h (+86/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/JSON/SBJsonBase.m (+78/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/JSON/SBJsonParser.h (+87/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/JSON/SBJsonParser.m (+475/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/JSON/SBJsonWriter.h (+129/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/JSON/SBJsonWriter.m (+237/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/facebook-ios-sdk.xcodeproj/project.pbxproj (+341/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/facebook-ios-sdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata (+7/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/facebook-ios-sdk.xcodeproj/project.xcworkspace/xcuserdata/mkijewski.xcuserdatad/UserInterfaceState.xcuserstate (+1867/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/facebook-ios-sdk.xcodeproj/xcuserdata/mkijewski.xcuserdatad/xcschemes/facebook-ios-sdk.xcscheme (+58/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/facebook-ios-sdk.xcodeproj/xcuserdata/mkijewski.xcuserdatad/xcschemes/xcschememanagement.plist (+22/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/src/facebook_ios_sdk_Prefix.pch (+7/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/test/UnitTest/Classes/UnitTestAppDelegate.h (+29/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/test/UnitTest/Classes/UnitTestAppDelegate.m (+43/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/test/UnitTest/Classes/UnitTestViewController.h (+39/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/test/UnitTest/Classes/UnitTestViewController.m (+321/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/test/UnitTest/Classes/UnitTestViewController.xib (+348/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/test/UnitTest/MainWindow.xib (+198/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/test/UnitTest/UnitTest-Info.plist (+30/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/test/UnitTest/UnitTest.xcodeproj/project.pbxproj (+332/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/test/UnitTest/UnitTest_Prefix.pch (+8/-0)
Dependencies/ShareKit/Submodules/facebook-ios-sdk/test/UnitTest/main.m (+17/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/.git (+1/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/.gitignore (+8/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/BridgeSupport/ObjectiveFlickr.bridgesupport (+43/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/CommandLineTool/CommandLineTool.xcodeproj/project.pbxproj (+260/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/CommandLineTool/main.m (+86/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/OAuthTransitionMac/OAuthTransitionMac.xcodeproj/project.pbxproj (+382/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/OAuthTransitionMac/OAuthTransitionMac/AppDelegate.h (+33/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/OAuthTransitionMac/OAuthTransitionMac/AppDelegate.m (+266/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/OAuthTransitionMac/OAuthTransitionMac/OAuthTransitionMac-Info.plist (+45/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/OAuthTransitionMac/OAuthTransitionMac/OAuthTransitionMac-Prefix.pch (+7/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/OAuthTransitionMac/OAuthTransitionMac/en.lproj/Credits.rtf (+29/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/OAuthTransitionMac/OAuthTransitionMac/en.lproj/InfoPlist.strings (+2/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/OAuthTransitionMac/OAuthTransitionMac/en.lproj/MainMenu.xib (+3758/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/OAuthTransitionMac/OAuthTransitionMac/main.m (+14/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/RandomPublicPhoto/English.lproj/MainMenu.xib (+3570/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/RandomPublicPhoto/Info.plist (+28/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/RandomPublicPhoto/MainWindowController.h (+40/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/RandomPublicPhoto/MainWindowController.m (+94/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/RandomPublicPhoto/RandomPublicPhoto.xcodeproj/project.pbxproj (+378/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/RandomPublicPhoto/RandomPublicPhoto_Prefix.pch (+7/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/RandomPublicPhoto/main.m (+33/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/SnapAndRun-iPhone/Classes/SnapAndRunAppDelegate.h (+64/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/SnapAndRun-iPhone/Classes/SnapAndRunAppDelegate.m (+200/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/SnapAndRun-iPhone/Classes/SnapAndRunViewController.h (+52/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/SnapAndRun-iPhone/Classes/SnapAndRunViewController.m (+304/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/SnapAndRun-iPhone/MainWindow.xib (+449/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/SnapAndRun-iPhone/SnapAndRun-Info.plist (+41/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/SnapAndRun-iPhone/SnapAndRun.xcodeproj/project.pbxproj (+340/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/SnapAndRun-iPhone/SnapAndRunViewController.xib (+345/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/SnapAndRun-iPhone/SnapAndRun_Prefix.pch (+8/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Examples/SnapAndRun-iPhone/main.m (+36/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/LFHTTPRequest.h (+163/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/LFHTTPRequest.m (+778/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/LFSiteReachability.h (+72/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/LFSiteReachability.m (+285/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/LFWebAPIKit.h (+35/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/NSData+LFHTTPFormExtensions.h (+33/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/NSData+LFHTTPFormExtensions.m (+50/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/SiteReachability-Mac/English.lproj/MainMenu.xib (+3229/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/SiteReachability-Mac/Info.plist (+28/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/SiteReachability-Mac/MainController.h (+24/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/SiteReachability-Mac/MainController.m (+62/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/SiteReachability-Mac/SiteReachability.xcodeproj/project.pbxproj (+315/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/SiteReachability-Mac/SiteReachability_Prefix.pch (+7/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/SiteReachability-Mac/main.m (+14/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/SiteReachability-Mac/version.plist (+16/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/SiteReachability-iPhone/Classes/SiteReachabilityAppDelegate.h (+22/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/SiteReachability-iPhone/Classes/SiteReachabilityAppDelegate.m (+33/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/SiteReachability-iPhone/Classes/SiteReachabilityViewController.h (+24/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/SiteReachability-iPhone/Classes/SiteReachabilityViewController.m (+77/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/SiteReachability-iPhone/MainWindow.xib (+218/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/SiteReachability-iPhone/SiteReachability-Info.plist (+30/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/SiteReachability-iPhone/SiteReachability.xcodeproj/project.pbxproj (+286/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/SiteReachability-iPhone/SiteReachabilityViewController.xib (+266/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/SiteReachability-iPhone/SiteReachability_Prefix.pch (+8/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/SiteReachability-iPhone/main.m (+17/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/StreamedBodySendingTest/AppDelegate.h (+41/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/StreamedBodySendingTest/AppDelegate.m (+86/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/StreamedBodySendingTest/English.lproj/MainMenu.xib (+3211/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/StreamedBodySendingTest/GoogleToolboxForMac-Part/COPYING (+202/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/StreamedBodySendingTest/GoogleToolboxForMac-Part/Foundation/GTMDebugSelectorValidation.h (+100/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/StreamedBodySendingTest/GoogleToolboxForMac-Part/Foundation/GTMGarbageCollection.h (+72/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/StreamedBodySendingTest/GoogleToolboxForMac-Part/Foundation/GTMHTTPServer.h (+137/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/StreamedBodySendingTest/GoogleToolboxForMac-Part/Foundation/GTMHTTPServer.m (+595/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/StreamedBodySendingTest/GoogleToolboxForMac-Part/GTMDefines.h (+241/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/StreamedBodySendingTest/Info.plist (+28/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/StreamedBodySendingTest/README.txt (+4/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/StreamedBodySendingTest/StreamedBodySendingTest.xcodeproj/project.pbxproj (+324/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/StreamedBodySendingTest/StreamedBodySendingTest_Prefix.pch (+28/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/StreamedBodySendingTest/main.m (+33/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/SynchronousRequestTest/SynchronousRequestTest-Info.plist (+20/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/SynchronousRequestTest/SynchronousRequestTest.xcodeproj/project.pbxproj (+234/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/SynchronousRequestTest/TestSuite.h (+17/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/LFWebAPIKit/Tests/SynchronousRequestTest/TestSuite.m (+42/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/ObjectiveFlickr-Info.plist (+20/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/ObjectiveFlickr.xcodeproj/project.pbxproj (+541/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/README.markdown (+681/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/SampleAPIKey.h.template (+29/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Source/OFUtilities.h (+39/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Source/OFUtilities.m (+366/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Source/OFXMLMapper.h (+53/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Source/OFXMLMapper.m (+154/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Source/ObjectiveFlickr.h (+206/-0)
Dependencies/ShareKit/Submodules/objectiveflickr/Source/ObjectiveFlickr.m (+801/-0)
Dependencies/ShareKit/Submodules/sskeychain/.git (+1/-0)
Dependencies/ShareKit/Submodules/sskeychain/.gitignore (+7/-0)
Dependencies/ShareKit/Submodules/sskeychain/Changelog.markdown (+30/-0)
Dependencies/ShareKit/Submodules/sskeychain/LICENSE (+20/-0)
Dependencies/ShareKit/Submodules/sskeychain/Rakefile (+38/-0)
Dependencies/ShareKit/Submodules/sskeychain/Readme.markdown (+60/-0)
Dependencies/ShareKit/Submodules/sskeychain/SSKeychain.h (+357/-0)
Dependencies/ShareKit/Submodules/sskeychain/SSKeychain.m (+262/-0)
Dependencies/ShareKit/Submodules/sskeychain/Tests/SSKeychain.xcodeproj/project.pbxproj (+383/-0)
Dependencies/ShareKit/Submodules/sskeychain/Tests/SSKeychainTests-Info.plist (+22/-0)
Dependencies/ShareKit/Submodules/sskeychain/Tests/SSKeychainTests.m (+53/-0)
Dependencies/ShareKit/Submodules/sskeychain/Tests/SSKeychainTestsARC-Info.plist (+22/-0)
Dependencies/ShareKit/Submodules/sskeychain/VERSION (+1/-0)
Dependencies/ShareKit/main.m (+17/-0)
Dependencies/oauthconsumer/Categories/NSMutableURLRequest+Parameters.h (+0/-37)
Dependencies/oauthconsumer/Categories/NSMutableURLRequest+Parameters.m (+0/-116)
Dependencies/oauthconsumer/Categories/NSString+URLEncoding.h (+0/-35)
Dependencies/oauthconsumer/Categories/NSString+URLEncoding.m (+0/-73)
Dependencies/oauthconsumer/Categories/NSURL+Base.h (+0/-34)
Dependencies/oauthconsumer/Categories/NSURL+Base.m (+0/-37)
Dependencies/oauthconsumer/Crypto/Base64Transcoder.c (+0/-230)
Dependencies/oauthconsumer/Crypto/Base64Transcoder.h (+0/-36)
Dependencies/oauthconsumer/Crypto/hmac.c (+0/-88)
Dependencies/oauthconsumer/Crypto/hmac.h (+0/-31)
Dependencies/oauthconsumer/Crypto/sha1.c (+0/-171)
Dependencies/oauthconsumer/Crypto/sha1.h (+0/-13)
Dependencies/oauthconsumer/OAAttachment.h (+0/-26)
Dependencies/oauthconsumer/OAAttachment.m (+0/-33)
Dependencies/oauthconsumer/OACall.h (+0/-63)
Dependencies/oauthconsumer/OACall.m (+0/-170)
Dependencies/oauthconsumer/OAConsumer.h (+0/-42)
Dependencies/oauthconsumer/OAConsumer.m (+0/-60)
Dependencies/oauthconsumer/OADataFetcher.h (+0/-44)
Dependencies/oauthconsumer/OADataFetcher.m (+0/-90)
Dependencies/oauthconsumer/OAHMAC_SHA1SignatureProvider.h (+0/-32)
Dependencies/oauthconsumer/OAHMAC_SHA1SignatureProvider.m (+0/-58)
Dependencies/oauthconsumer/OAMutableURLRequest.h (+0/-65)
Dependencies/oauthconsumer/OAMutableURLRequest.m (+0/-222)
Dependencies/oauthconsumer/OAPlaintextSignatureProvider.h (+0/-31)
Dependencies/oauthconsumer/OAPlaintextSignatureProvider.m (+0/-40)
Dependencies/oauthconsumer/OAProblem.h (+0/-53)
Dependencies/oauthconsumer/OAProblem.m (+0/-172)
Dependencies/oauthconsumer/OARequestParameter.h (+0/-48)
Dependencies/oauthconsumer/OARequestParameter.m (+0/-80)
Dependencies/oauthconsumer/OAServiceTicket.h (+0/-46)
Dependencies/oauthconsumer/OAServiceTicket.m (+0/-59)
Dependencies/oauthconsumer/OASignatureProviding.h (+0/-34)
Dependencies/oauthconsumer/OATestServer.rb (+0/-37)
Dependencies/oauthconsumer/OAToken.h (+0/-73)
Dependencies/oauthconsumer/OAToken.m (+0/-356)
Dependencies/oauthconsumer/OATokenManager.h (+0/-68)
Dependencies/oauthconsumer/OATokenManager.m (+0/-403)
Dependencies/oauthconsumer/OAuthConsumer.h (+0/-40)
Dependencies/oauthconsumer/README (+0/-15)
Files.xcodeproj/project.pbxproj (+619/-174)
Files/Files-Info.plist (+3/-0)
Files/FilesAppDelegate.m (+16/-0)
Files/U1FileDetailsViewController.h (+3/-0)
Files/U1FileDetailsViewController.m (+24/-0)
Files/U1FileDetailsViewController.xib (+69/-202)
Files/U1FilePreviewViewController.h (+3/-0)
Files/U1FilePreviewViewController.m (+25/-0)
Files/U1FilePreviewViewController.xib (+87/-13)
Files/U1FilesService.m (+2/-2)
Files/U1ShareKitConfigurator.h (+21/-0)
Files/U1ShareKitConfigurator.m (+131/-0)
Files/U1Sharers.plist (+18/-0)
To merge this branch: bzr merge lp:~jose-exposito89/ubuntuone-ios-files/social-networking
Reviewer Review Type Date Requested Status
Ubuntu One iOS Client Team Pending
Review via email: mp+131047@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) wrote :

A few comments:

  (1) Why does this diff show the removal of JSONKit? Would it be possible to base your patch off current trunk?
  (2) While I appreciate the use of a library, there are some git artifacts that lead me to believe this is a trunk version, rather than a released version. Is there a released version we can use instead?
  (3) I've been wanting to move in a direction of having our dependent libraries compiled as universal .so files, or at least dependent projects within Xcode.

Revision history for this message
José Expósito (jose-exposito89) wrote :

Hello Paul,

(1) In order to be able to share links, I have added the ShareKit dependency, that includes into their dependencies JSONKit, for this reason the libs are not removed, they are in other directories.

(2) I have incorporated the trunk because it adds more share services. Anyway, it's possible to change it for the only tag of the project:
https://github.com/ShareKit/ShareKit/tags
But I can say that the trunk is very stable, I use it in my work, in a "real application" without any problem... Anyway, I can change it if you prefer

(3) In my opinion this is the better way of integrate dependencies, in fact, in my ARC branch I have integrating all the dependencies as universal frameworks (a bundle with the library and the headers) to easy make it ARC compatible and easy to update, add, or remove:

http://bazaar.launchpad.net/~jose-exposito89/ubuntuone-ios-files/arc/files/head:/Dependencies/

The ARC branch is mature, but I'm waiting for instructions or help to update the core data to proporse it for merge...
https://lists.launchpad.net/ubuntuone-users/msg00749.html

Unmerged revisions

62. By José Expósito

Added support to share links in social networks

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed directory 'Dependencies/JSONKit'
2=== removed file 'Dependencies/JSONKit/CHANGELOG.md'
3--- Dependencies/JSONKit/CHANGELOG.md 2011-08-31 14:56:30 +0000
4+++ Dependencies/JSONKit/CHANGELOG.md 1970-01-01 00:00:00 +0000
5@@ -1,389 +0,0 @@
6-# JSONKit Changelog
7-
8-## Version 1.X ????/??/??
9-
10-**IMPORTANT:** The following changelog notes are a work in progress. They apply to the work done on JSONKit post v1.4. Since JSONKit itself is inbetween versions, these changelog notes are subject to change, may be wrong, and just about everything else you could expect at this point in development.
11-
12-### New Features
13-
14-* When `JKSerializeOptionPretty` is enabled, JSONKit now sorts the keys.
15-
16-* Normally, JSONKit can only serialize NSNull, NSNumber, NSString, NSArray, and NSDictioonary like objects. It is now possible to serialize an object of any class via either a delegate or a `^` block.
17-
18- The delegate or `^` block must return an object that can be serialized by JSONKit, however, otherwise JSONKit will fail to serialize the object. In other words, JSONKit tries to serialize an unsupported class of the object just once, and if the delegate or ^block returns another unsupported class, the second attempt to serialize will fail. In practice, this is not a problem at all, but it does prevent endless recursive attempts to serialize an unsupported class.
19-
20- This makes it trivial to serialize objects like NSDate or NSData. A NSDate object can be formatted using a NSDateFormatter to return a ISO-8601 `YYYY-MM-DDTHH:MM:SS.sssZ` type object, for example. Or a NSData object could be Base64 encoded.
21-
22- This greatly simplifies things when you have a complex, nested objects with objects that do not belong to the classes that JSONKit can serialize.
23-
24- It should be noted that the same caching that JSONKit does for the supported class types also applies to the objects of an unsupported class- if the same object is serialized more than once and the object is still in the serialization cache, JSONKit will copy the previous serialization result instead of invoking the delegate or `^` block again. Therefore, you should not expect or depend on your delegate or block being called each time the same object needs to be serialized AND the delegate or block MUST return a "formatted object" that is STRICTLY invariant (that is to say the same object must always return the exact same formatted output).
25-
26- To serialize NSArray or NSDictionary objects using a delegate–
27-
28- **NOTE:** The delegate is based a single argument, the object with the unsupported class, and the supplied `selector` method must be one that accepts a single `id` type argument (i.e., `formatObject:`).
29- **IMPORTANT:** The `^` block MUST return an object with a class that can be serialized by JSONKit, otherwise the serialization will fail.
30-
31- <pre>
32- &#x200b;- (NSData \*)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError \*\*)error;
33- &#x200b;- (NSString \*)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError \*\*)error;
34- </pre>
35-
36- To serialize NSArray or NSDictionary objects using a `^` block&ndash;
37-
38- **NOTE:** The block is passed a single argument, the object with the unsupported class.
39- **IMPORTANT:** The `^` block MUST return an object with a class that can be serialized by JSONKit, otherwise the serialization will fail.
40-
41- <pre>
42- &#x200b;- (NSData \*)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(&#x005E;)(id object))block error:(NSError \*\*)error;
43- &#x200b;- (NSString \*)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(&#x005E;)(id object))block error:(NSError \*\*)error;
44- </pre>
45-
46- Example using the delegate way:
47-
48- <pre>
49- @interface MYFormatter : NSObject {
50- NSDateFormatter \*outputFormatter;
51- }
52- @end
53- &#x200b;
54- @implementation MYFormatter
55- -(id)init
56- {
57- if((self = [super init]) == NULL) { return(NULL); }
58- if((outputFormatter = [[NSDateFormatter alloc] init]) == NULL) { [self autorelease]; return(NULL); }
59- [outputFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZZZ"];
60- return(self);
61- }
62- &#x200b;
63- -(void)dealloc
64- {
65- if(outputFormatter != NULL) { [outputFormatter release]; outputFormatter = NULL; }
66- [super dealloc];
67- }
68- &#x200b;
69- -(id)formatObject:(id)object
70- {
71- if([object isKindOfClass:[NSDate class]]) { return([outputFormatter stringFromDate:object]); }
72- return(NULL);
73- }
74- @end
75- &#x200b;
76- {
77- MYFormatter \*myFormatter = [[[MYFormatter alloc] init] autorelease];
78- NSArray \*array = [NSArray arrayWithObject:[NSDate dateWithTimeIntervalSinceNow:0.0]];
79-
80- NSString \*jsonString = NULL;
81- jsonString = [array JSONStringWithOptions:JKSerializeOptionNone
82- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;serializeUnsupportedClassesUsingDelegate:myFormatter
83- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;selector:@selector(formatObject:)
84- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;error:NULL];
85- NSLog(@"jsonString: '%@'", jsonString);
86- // 2011-03-25 11:42:16.175 formatter_example[59120:903] jsonString: '["2011-03-25T11:42:16.175-0400"]'
87- }
88- </pre>
89-
90- Example using the `^` block way:
91-
92- <pre>
93- {
94- NSDateFormatter \*outputFormatter = [[[NSDateFormatter alloc] init] autorelease];
95- [outputFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZZZ"];
96- &#x200b;
97- jsonString = [array JSONStringWithOptions:encodeOptions
98- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;serializeUnsupportedClassesUsingBlock:&#x005E;id(id object) {
99- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if([object isKindOfClass:[NSDate class]]) { return([outputFormatter stringFromDate:object]); }
100- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return(NULL);
101- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
102- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;error:NULL];
103- NSLog(@"jsonString: '%@'", jsonString);
104- // 2011-03-25 11:49:56.434 json_parse[59167:903] jsonString: '["2011-03-25T11:49:56.434-0400"]'
105- }
106- </pre>
107-
108-### Major Changes
109-
110-* The way that JSONKit implements the collection classes was modified. Specifically, JSONKit now follows the same strategy that the Cocoa collection classes use, which is to have a single subclass of the mutable collection class. This concrete subclass has an ivar bit that determines whether or not that instance is mutable, and when an immutable instance receives a mutating message, it throws an exception.
111-
112-## Version 1.4 2011/23/03
113-
114-### Highlights
115-
116-* JSONKit v1.4 significantly improves the performance of serializing and deserializing. Deserializing is 23% faster than Apples binary `.plist`, and an amazing 549% faster than Apples binary `.plist` when serializing.
117-
118-### New Features
119-
120-* JSONKit can now return mutable collection classes.
121-* The `JKSerializeOptionFlags` option `JKSerializeOptionPretty` was implemented.
122-* It is now possible to serialize a single [`NSString`][NSString]. This functionality was requested in issue #4 and issue #11.
123-
124-### Deprecated Methods
125-
126-* The following `JSONDecoder` methods are deprecated beginning with JSONKit v1.4 and will be removed in a later release&ndash;
127-
128- <pre>
129- &#x200b;- (id)parseUTF8String:(const unsigned char \*)string length:(size_t)length;
130- &#x200b;- (id)parseUTF8String:(const unsigned char \*)string length:(size_t)length error:(NSError \*\*)error;
131- &#x200b;- (id)parseJSONData:(NSData \*)jsonData;
132- &#x200b;- (id)parseJSONData:(NSData \*)jsonData error:(NSError \*\*)error;
133- </pre>
134-
135- The JSONKit v1.4 <code>objectWith&hellip;</code> methods should be used instead.
136-
137-### NEW API's
138-
139-* The following methods were added to `JSONDecoder`&ndash;
140-
141- These methods replace their deprecated <code>parse&hellip;</code> counterparts and return immutable collection objects.
142-
143- <pre>
144- &#x200b;- (id)objectWithUTF8String:(const unsigned char \*)string length:(NSUInteger)length;
145- &#x200b;- (id)objectWithUTF8String:(const unsigned char \*)string length:(NSUInteger)length error:(NSError \*\*)error;
146- &#x200b;- (id)objectWithData:(NSData \*)jsonData;
147- &#x200b;- (id)objectWithData:(NSData \*)jsonData error:(NSError \*\*)error;
148- </pre>
149-
150- These methods are the same as their <code>objectWith&hellip;</code> counterparts except they return mutable collection objects.
151-
152- <pre>
153- &#x200b;- (id)mutableObjectWithUTF8String:(const unsigned char \*)string length:(NSUInteger)length;
154- &#x200b;- (id)mutableObjectWithUTF8String:(const unsigned char \*)string length:(NSUInteger)length error:(NSError \*\*)error;
155- &#x200b;- (id)mutableObjectWithData:(NSData \*)jsonData;
156- &#x200b;- (id)mutableObjectWithData:(NSData \*)jsonData error:(NSError \*\*)error;
157- </pre>
158-
159-* The following methods were added to `NSString (JSONKitDeserializing)`&ndash;
160-
161- These methods are the same as their <code>objectFrom&hellip;</code> counterparts except they return mutable collection objects.
162-
163- <pre>
164- &#x200b;- (id)mutableObjectFromJSONString;
165- &#x200b;- (id)mutableObjectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
166- &#x200b;- (id)mutableObjectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError \*\*)error;
167- </pre>
168-
169-* The following methods were added to `NSData (JSONKitDeserializing)`&ndash;
170-
171- These methods are the same as their <code>objectFrom&hellip;</code> counterparts except they return mutable collection objects.
172-
173- <pre>
174- &#x200b;- (id)mutableObjectFromJSONData;
175- &#x200b;- (id)mutableObjectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
176- &#x200b;- (id)mutableObjectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError \*\*)error;
177- </pre>
178-
179-* The following methods were added to `NSString (JSONKitSerializing)`&ndash;
180-
181- These methods are for those uses that need to serialize a single [`NSString`][NSString]&ndash;
182-
183- <pre>
184- &#x200b;- (NSData \*)JSONData;
185- &#x200b;- (NSData \*)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions includeQuotes:(BOOL)includeQuotes error:(NSError \*\*)error;
186- &#x200b;- (NSString \*)JSONString;
187- &#x200b;- (NSString \*)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions includeQuotes:(BOOL)includeQuotes error:(NSError \*\*)error;
188- </pre>
189-
190-### Bug Fixes
191-
192-* JSONKit has a fast and a slow path for parsing JSON Strings. The slow path is needed whenever special string processing is required, such as the conversion of `\` escape sequences or ill-formed UTF-8. Although the slow path had a check for characters < `0x20`, which are not permitted by the [RFC 4627][], there was a bug such that the condition was never actually checked. As a result, JSONKit would have incorrectly accepted JSON that contained characters < `0x20` if it was using the slow path to process a JSON String.
193-* The low surrogate in a <code>\u<i><b>high</b></i>\u<i><b>low</b></i></code> escape sequence in a JSON String was incorrectly treating `dfff` as ill-formed Unicode. This was due to a comparison that used `>= 0xdfff` instead of `> 0xdfff` as it should have.
194-* `JKParseOptionLooseUnicode` was not properly honored when parsing some types of ill-formed Unicode in <code>\u<i><b>HHHH</b></i></code> escapes in JSON Strings.
195-
196-### Important Notes
197-
198-* JSONKit v1.4 now uses custom concrete subclasses of [`NSArray`][NSArray], [`NSMutableArray`][NSMutableArray], [`NSDictionary`][NSDictionary], and [`NSMutableDictionary`][NSMutableDictionary]&mdash; `JKArray`, `JKMutableArray`, `JKDictionary`, and `JKMutableDictionary`. respectively. These classes are internal and private to JSONKit, you should not instantiate objects from these classes directly.
199-
200- In theory, these custom classes should behave exactly the same as the respective Foundation / Cocoa counterparts.
201-
202- As usual, in practice may have non-linear excursions from what theory predicts. It is also virtually impossible to properly test or predict how these custom classes will interact with software in the wild.
203-
204- Most likely, if you do encounter a problem, it will happen very quickly, and you should report a bug via the [github.com JSONKit Issue Tracker][bugtracker].
205-
206- In addition to the required class cluster primitive methods, the custom collection classes also include support for [`NSFastEnumeration`][NSFastEnumeration], along with methods that support the bulk retrieval of the objects contents.
207-
208- #### Exceptions Thrown
209-
210- The JSONKit collection classes will throw the same exceptions for the same conditions as their respective Foundation counterparts. If you find a discrepancy, please report a bug via the [github.com JSONKit Issue Tracker][bugtracker].
211-
212- #### Multithreading Safety
213-
214- The same multithreading rules and caveats for the Foundation collection classes apply to the JSONKit collection classes. Specifically, it should be safe to use the immutable collections from multiple threads concurrently.
215-
216- The mutable collections can be used from multiple threads as long as you provide some form of mutex barrier that ensures that if a thread needs to mutate the collection, then it has exclusive access to the collection&ndash; no other thread can be reading from or writing to the collection until the mutating thread has finished. Failure to ensure that there are no other threads reading or writing from the mutable collection when a thread mutates the collection will result in `undefined` behavior.
217-
218- #### Mutable Collection Notes
219-
220- The mutable versions of the collection classes are meant to be used when you need to make minor modifications to the collection. Neither `JKMutableArray` or `JKMutableDictionary` have been optimized for nor are they intended to be used in situations where you are adding a large number of objects or new keys&ndash; these types of operations will cause both classes to frequently reallocate the memory used to hold the objects in the collection.
221-
222- #### `JKMutableArray` Usage Notes
223-
224- * You should minimize the number of new objects you added to the array. The array is not designed for high performance insertion and removal of objects. If the array does not have any extra capacity it must reallocate the backing store. When the array is forced to grow the backing store, it currently adds an additional 16 slots worth of spare capacity. The array is instantiated without any extra capacity on the assumption that dictionaries are going to be mutated more than arrays. The array never shrinks the backing store.
225-
226- * Replacing objects in the array via [`-replaceObjectAtIndex:withObject:`][-replaceObjectAtIndex:withObject:] is very fast since the array simply releases the current object at the index and replaces it with the new object.
227-
228- * Inserting an object in to the array via [`-insertObject:atIndex:`][-insertObject:atIndex:] cause the array to [`memmove()`][memmove] all the objects up one slot from the insertion index. This means this operation is fastest when inserting objects at the last index since no objects need to be moved.
229-
230- * Removing an object from the array via [`-removeObjectAtIndex:`][-removeObjectAtIndex:] causes the array to [`memmove()`][memmove] all the objects down one slot from the removal index. This means this operation is fastest when removing objects at the last index since no objects need to be moved. The array will not resize its backing store to a smaller size.
231-
232- * [`-copy`][-copy] and [`-mutableCopy`][-mutableCopy] will instantiate a new [`NSArray`][NSArray] or [`NSMutableArray`][NSMutableArray] class object, respectively, with the contents of the receiver.
233-
234- #### `JKMutableDictionary` Usage Notes
235-
236- * You should minimize the number of new keys you add to the dictionary. If the number of items in the dictionary exceeds a threshold value it will trigger a resizing operation. To do this, the dictionary must allocate a new, larger backing store, and then re-add all the items in the dictionary by rehashing them to the size of the newer, larger store. This is an expensive operation. While this is a limitation of nearly all hash tables, the capacity for the hash table used by `JKMutableDictionary` has been chosen to minimize the amount of memory used since it is anticipated that most dictionaries will not grow significantly once they are instantiated.
237-
238- * If the key already exists in the dictionary and you change the object associated with it via [`-setObject:forKey:`][-setObject:forKey:], this will not cause any performance problems or trigger a hash table resize.
239-
240- * Removing a key from the dictionary via [`-removeObjectForKey:`][-removeObjectForKey:] will not cause any performance problems. However, the dictionary will not resize its backing store to the smaller size.
241-
242- * [`-copy`][-copy] and [`-mutableCopy`][-mutableCopy] will instantiate a new [`NSDictionary`][NSDictionary] or [`NSMutableDictionary`][NSMutableDictionary] class object, respectively, with the contents of the receiver.
243-
244-### Major Changes
245-
246-* The `JK_ENABLE_CF_TRANSFER_OWNERSHIP_CALLBACKS` pre-processor define flag that was added to JSONKit v1.3 has been removed.
247-
248- `JK_ENABLE_CF_TRANSFER_OWNERSHIP_CALLBACKS` was added in JSONKit v1.3 as a temporary work around. While the author was aware of other ways to fix the particular problem caused by the usage of "transfer of ownership callbacks" with Core Foundation classes, the fix provided in JSONKit v1.3 was trivial to implement. This allowed people who needed that functionality to use JSONKit while a proper solution to the problem was worked on. JSONKit v1.4 is the result of that work.
249-
250- JSONKit v1.4 no longer uses the Core Foundation collection classes [`CFArray`][CFArray] and [`CFDictionary`][CFDictionary]. Instead, JSONKit v1.4 contains a concrete subclass of [`NSArray`][NSArray] and [`NSDictionary`][NSDictionary]&ndash; `JKArray` and `JKDictionary`, respectively. As a result, JSONKit has complete control over the behavior of how items are added and managed within an instantiated collection object. The `JKArray` and `JKDictionary` classes are private to JSONKit, you should not instantiate them direction. Since they are concrete subclasses of their respective collection class cluster, they behave and act exactly the same as [`NSArray`][NSArray] and [`NSDictionary`][NSDictionary].
251-
252- The first benefit is that the "transfer of ownership" object ownership policy can now be safely used. Because the JSONKit collection objects understand that some methods, such as [`-mutableCopy`][-mutableCopy], should not inherit the same "transfer of ownership" object ownership policy, but must follow the standard Cocoa object ownership policy. The "transfer of ownership" object ownership policy reduces the number of [`-retain`][-retain] and [`-release`][-release] calls needed to add an object to a collection, and when creating a large number of objects very quickly (as you would expect when parsing JSON), this can result in a non-trivial amount of time. Eliminating these calls means faster JSON parsing.
253-
254- A second benefit is that the author encountered some unexpected behavior when using the [`CFDictionaryCreate`][CFDictionaryCreate] function to create a dictionary and the `keys` argument contained duplicate keys. This required JSONKit to de-duplicate the keys and values before calling [`CFDictionaryCreate`][CFDictionaryCreate]. Unfortunately, JSONKit always had to scan all the keys to make sure there were no duplicates, even though 99.99% of the time there were none. This was less than optimal, particularly because one of the solutions to this particular problem is to use a hash table to perform the de-duplication. Now JSONKit can do the de-duplication while it is instantiating the dictionary collection, solving two problems at once.
255-
256- Yet another benefit is that the recently instantiated object cache that JSONKit uses can be used to cache information about the keys used to create dictionary collections, in particular a keys [`-hash`][-hash] value. For a lot of real world JSON, this effectively means that the [`-hash`][-hash] for a key is calculated once, and that value is reused again and again when creating dictionaries. Because all the information required to create the hash table used by `JKDictionary` is already determined at the time the `JKDictionary` object is instantiated, populating the `JKDictionary` is now a very tight loop that only has to call [`-isEqual:`][-isEqual:] on the rare occasions that the JSON being parsed contains duplicate keys. Since the functions that handle this logic are all declared `static` and are internal to JSONKit, the compiler can heavily optimize this code.
257-
258- What does this mean in terms of performance? JSONKit was already fast, but now, it's even faster. Below is some benchmark times for [`twitter_public_timeline.json`][twitter_public_timeline.json] in [samsoffes / json-benchmarks](https://github.com/samsoffes/json-benchmarks), where _read_ means to convert the JSON to native Objective-C objects, and _write_ means to convert the native Objective-C to JSON&mdash;
259-
260- <pre>
261- v1.3 read : min: 456.000 us, avg: 460.056 us, char/s: 53341332.36 / 50.870 MB/s
262- v1.3 write: min: 150.000 us, avg: 151.816 us, char/s: 161643041.58 / 154.155 MB/s</pre>
263-
264- <pre>
265- v1.4 read : min: 285.000 us, avg: 288.603 us, char/s: 85030301.14 / 81.091 MB/s
266- v1.4 write: min: 127.000 us, avg: 129.617 us, char/s: 189327017.29 / 180.556 MB/s</pre>
267-
268- JSONKit v1.4 is nearly 60% faster at reading and 17% faster at writing than v1.3.
269-
270- The following is the JSON test file taken from the project available at [this blog post](http://psionides.jogger.pl/2010/12/12/cocoa-json-parsing-libraries-part-2/). The keys and information contained in the JSON was anonymized with random characters. Since JSONKit relies on its recently instantiated object cache for a lot of its performance, this JSON happens to be "the worst corner case possible".
271-
272- <pre>
273- v1.3 read : min: 5222.000 us, avg: 5262.344 us, char/s: 15585260.10 / 14.863 MB/s
274- v1.3 write: min: 1253.000 us, avg: 1259.914 us, char/s: 65095712.88 / 62.080 MB/s</pre>
275-
276- <pre>
277- v1.4 read : min: 4096.000 us, avg: 4122.240 us, char/s: 19895736.30 / 18.974 MB/s
278- v1.4 write: min: 1319.000 us, avg: 1335.538 us, char/s: 61409709.05 / 58.565 MB/s</pre>
279-
280- JSONKit v1.4 is 28% faster at reading and 6% faster at writing that v1.3 in this worst-case torture test.
281-
282- While your milage may vary, you will likely see improvements in the 50% for reading and 10% for writing on your real world JSON. The nature of JSONKits cache means performance improvements is statistical in nature and depends on the particular properties of the JSON being parsed.
283-
284- For comparison, [json-framework][], a popular Objective-C JSON parsing library, turns in the following benchmark times for [`twitter_public_timeline.json`][twitter_public_timeline.json]&mdash;
285-
286- <pre>
287- &#x200b; read : min: 1670.000 us, avg: 1682.461 us, char/s: 14585776.43 / 13.910 MB/s
288- &#x200b; write: min: 1021.000 us, avg: 1028.970 us, char/s: 23849091.81 / 22.744 MB/s</pre>
289-
290- Since the benchmark for JSONKit and [json-framework][] was done on the same computer, it's safe to compare the timing results. The version of [json-framework][] used was the latest v3.0 available via the master branch at the time of this writing on github.com.
291-
292- JSONKit v1.4 is 483% faster at reading and 694% faster at writing than [json-framework][].
293-
294-### Other Changes
295-
296-* Added a `__clang_analyzer__` pre-processor conditional around some code that the `clang` static analyzer was giving false positives for. However, `clang` versions &le; 1.5 do not define `__clang_analyzer__` and therefore will continue to emit analyzer warnings.
297-* The cache now uses a Galois Linear Feedback Shift Register PRNG to select which item in the cache to randomly age. This should age items in the cache more fairly.
298-* To promote better L1 cache locality, the cache age structure was rearranged slightly along with modifying when an item is randomly chosen to be aged.
299-* Removed a lot of internal and private data structures from `JSONKit.h` and put them in `JSONKit.m`.
300-* Modified the way floating point values are serialized. Previously, the [`printf`][printf] format conversion `%.16g` was used. This was changed to `%.17g` which should theoretically allow for up to a full `float`, or [IEEE 754 Single 32-bit floating-point][Single Precision], of precision when converting floating point values to decimal representation.
301-* The usual sundry of inconsequential tidies and what not, such as updating the `README.md`, etc.
302-* The catagory additions to the Cocoa classes were changed from `JSONKit` to `JSONKitDeserializing` and `JSONKitSerializing`, as appropriate.
303-
304-## Version 1.3 2011/05/02
305-
306-### New Features
307-
308-* Added the `JK_ENABLE_CF_TRANSFER_OWNERSHIP_CALLBACKS` pre-processor define flag.
309-
310- This is typically enabled by adding `-DJK_ENABLE_CF_TRANSFER_OWNERSHIP_CALLBACKS` to the compilers command line arguments or in `Xcode.app` by adding `JK_ENABLE_CF_TRANSFER_OWNERSHIP_CALLBACKS` to a projects / targets `Pre-Processor Macros` settings.
311-
312- The `JK_ENABLE_CF_TRANSFER_OWNERSHIP_CALLBACKS` option enables the use of custom Core Foundation collection call backs which omit the [`CFRetain`][CFRetain] calls. This results in saving several [`CFRetain`][CFRetain] and [`CFRelease`][CFRelease] calls typically needed for every single object from the parsed JSON. While the author has used this technique for years without any issues, an unexpected interaction with the Foundation [`-mutableCopy`][-mutableCopy] method and Core Foundation Toll-Free Bridging resulting in a condition in which the objects contained in the collection to be over released. This problem does not occur with the use of [`-copy`][-copy] due to the fact that the objects created by JSONKit are immutable, and therefore [`-copy`][-copy] does not require creating a completely new object and copying the contents, instead [`-copy`][-copy] simply returns a [`-retain`][-retain]'d version of the immutable object which is significantly faster along with the obvious reduction in memory usage.
313-
314- Prior to version 1.3, JSONKit always used custom "Transfer of Ownership Collection Callbacks", and thus `JK_ENABLE_CF_TRANSFER_OWNERSHIP_CALLBACKS` was effectively implicitly defined.
315-
316- Beginning with version 1.3, the default behavior of JSONKit is to use the standard Core Foundation collection callbacks ([`kCFTypeArrayCallBacks`][kCFTypeArrayCallBacks], [`kCFTypeDictionaryKeyCallBacks`][kCFTypeDictionaryKeyCallBacks], and [`kCFTypeDictionaryValueCallBacks`][kCFTypeDictionaryValueCallBacks]). The intention is to follow "the principle of least surprise", and the author believes the use of the standard Core Foundation collection callbacks as the default behavior for JSONKit results in the least surprise.
317-
318- **NOTE**: `JK_ENABLE_CF_TRANSFER_OWNERSHIP_CALLBACKS` is only applicable to `(CF|NS)` `Dictionary` and `Array` class objects.
319-
320- For the vast majority of users, the author believes JSONKits custom "Transfer of Ownership Collection Callbacks" will not cause any problems. As previously stated, the author has used this technique in performance critical code for years and has never had a problem. Until a user reported a problem with [`-mutableCopy`][-mutableCopy], the author was unaware that the use of the custom callbacks could even cause a problem. This is probably due to the fact that the vast majority of time the typical usage pattern tends to be "iterate the contents of the collection" and very rarely mutate the returned collection directly (although this last part is likely to vary significantly from programmer to programmer). The author tends to avoid the use of [`-mutableCopy`][-mutableCopy] as it results in a significant performance and memory consumption penalty. The reason for this is in "typical" Cocoa coding patterns, using [`-mutableCopy`][-mutableCopy] will instantiate an identical, albeit mutable, version of the original object. This requires both memory for the new object and time to iterate the contents of the original object and add them to the new object. Furthermore, under "typical" Cocoa coding patterns, the original collection object continues to consume memory until the autorelease pool is released. However, clearly there are cases where the use of [`-mutableCopy`][-mutableCopy] makes sense or may be used by an external library which is out of your direct control.
321-
322- The use of the standard Core Foundation collection callbacks results in a 9% to 23% reduction in parsing performance, with an "eye-balled average" of around 13% according to some benchmarking done by the author using Real World&trade; JSON (i.e., actual JSON from various web services, such as Twitter, etc) using `gcc-4.2 -arch x86_64 -O3 -DNS_BLOCK_ASSERTIONS` with the only change being the addition of `-DJK_ENABLE_CF_TRANSFER_OWNERSHIP_CALLBACKS`.
323-
324- `JK_ENABLE_CF_TRANSFER_OWNERSHIP_CALLBACKS` is only applicable to parsing / deserializing (i.e. converting from) of JSON. Serializing (i.e., converting to JSON) is completely unaffected by this change.
325-
326-### Bug Fixes
327-
328-* Fixed a [bug report regarding `-mutableCopy`](https://github.com/johnezang/JSONKit/issues#issue/3). This is related to the addition of the pre-processor define flag `JK_ENABLE_CF_TRANSFER_OWNERSHIP_CALLBACKS`.
329-
330-### Other Changes
331-
332-* Added `JK_EXPECTED` optimization hints around several conditionals.
333-* When serializing objects, JSONKit first starts with a small, on stack buffer. If the encoded JSON exceeds the size of the stack buffer, JSONKit switches to a heap allocated buffer. If JSONKit switched to a heap allocated buffer, [`CFDataCreateWithBytesNoCopy`][CFDataCreateWithBytesNoCopy] is used to create the [`NSData`][NSData] object, which in most cases causes the heap allocated buffer to "transfer" to the [`NSData`][NSData] object which is substantially faster than allocating a new buffer and copying the bytes.
334-* Added a pre-processor check in `JSONKit.m` to see if Objective-C Garbage Collection is enabled and issue a `#error` notice that JSONKit does not support Objective-C Garbage Collection.
335-* Various other minor or trivial modifications, such as updating `README.md`.
336-
337-### Other Issues
338-
339-* When using the `clang` static analyzer (the version used at the time of this writing was `Apple clang version 1.5 (tags/Apple/clang-60)`), the static analyzer reports a number of problems with `JSONKit.m`.
340-
341- The author has investigated these issues and determined that the problems reported by the current version of the static analyzer are "false positives". Not only that, the reported problems are not only "false positives", they are very clearly and obviously wrong. Therefore, the author has made the decision that no action will be taken on these non-problems, which includes not modifying the code for the sole purpose of silencing the static analyzer. The justification for this is "the dog wags the tail, not the other way around."
342-
343-## Version 1.2 2011/01/08
344-
345-### Bug Fixes
346-
347-* When JSONKit attempted to parse and decode JSON that contained `{"key": value}` dictionaries that contained the same key more than once would likely result in a crash. This was a serious bug.
348-* Under some conditions, JSONKit could potentially leak memory.
349-* There was an off by one error in the code that checked whether or not the parser was at the end of the `UTF8` buffer. This could result in JSONKit reading one by past the buffer bounds in some cases.
350-
351-### Other Changes
352-
353-* Some of the methods were missing `NULL` pointer checks for some of their arguments. This was fixed. In generally, when JSONKit encounters invalid arguments, it throws a `NSInvalidArgumentException` exception.
354-* Various other minor changes such as tightening up numeric literals with `UL` or `L` qualification, assertion check tweaks and additions, etc.
355-* The README.md file was updated with additional information.
356-
357-### Version 1.1
358-
359-No change log information was kept for versions prior to 1.2.
360-
361-[bugtracker]: https://github.com/johnezang/JSONKit/issues
362-[RFC 4627]: http://tools.ietf.org/html/rfc4627
363-[twitter_public_timeline.json]: https://github.com/samsoffes/json-benchmarks/blob/master/Resources/twitter_public_timeline.json
364-[json-framework]: https://github.com/stig/json-framework
365-[Single Precision]: http://en.wikipedia.org/wiki/Single_precision
366-[kCFTypeArrayCallBacks]: http://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFArrayRef/Reference/reference.html#//apple_ref/c/data/kCFTypeArrayCallBacks
367-[kCFTypeDictionaryKeyCallBacks]: http://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFDictionaryRef/Reference/reference.html#//apple_ref/c/data/kCFTypeDictionaryKeyCallBacks
368-[kCFTypeDictionaryValueCallBacks]: http://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFDictionaryRef/Reference/reference.html#//apple_ref/c/data/kCFTypeDictionaryValueCallBacks
369-[CFRetain]: http://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFTypeRef/Reference/reference.html#//apple_ref/c/func/CFRetain
370-[CFRelease]: http://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFTypeRef/Reference/reference.html#//apple_ref/c/func/CFRelease
371-[CFDataCreateWithBytesNoCopy]: http://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFDataRef/Reference/reference.html#//apple_ref/c/func/CFDataCreateWithBytesNoCopy
372-[CFArray]: http://developer.apple.com/library/mac/#documentation/CoreFoundation/Reference/CFArrayRef/Reference/reference.html
373-[CFDictionary]: http://developer.apple.com/library/mac/#documentation/CoreFoundation/Reference/CFDictionaryRef/Reference/reference.html
374-[CFDictionaryCreate]: http://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFDictionaryRef/Reference/reference.html#//apple_ref/c/func/CFDictionaryCreate
375-[-mutableCopy]: http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/Reference/Reference.html%23//apple_ref/occ/instm/NSObject/mutableCopy
376-[-copy]: http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/Reference/Reference.html%23//apple_ref/occ/instm/NSObject/copy
377-[-retain]: http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Protocols/NSObject_Protocol/Reference/NSObject.html#//apple_ref/occ/intfm/NSObject/retain
378-[-release]: http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Protocols/NSObject_Protocol/Reference/NSObject.html#//apple_ref/occ/intfm/NSObject/release
379-[-isEqual:]: http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Protocols/NSObject_Protocol/Reference/NSObject.html#//apple_ref/occ/intfm/NSObject/isEqual:
380-[-hash]: http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Protocols/NSObject_Protocol/Reference/NSObject.html#//apple_ref/occ/intfm/NSObject/hash
381-[NSArray]: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/index.html
382-[NSMutableArray]: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/index.html
383-[-insertObject:atIndex:]: http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/Reference/Reference.html#//apple_ref/occ/instm/NSMutableArray/insertObject:atIndex:
384-[-removeObjectAtIndex:]: http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/Reference/Reference.html#//apple_ref/occ/instm/NSMutableArray/removeObjectAtIndex:
385-[-replaceObjectAtIndex:withObject:]: http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/Reference/Reference.html#//apple_ref/occ/instm/NSMutableArray/replaceObjectAtIndex:withObject:
386-[NSDictionary]: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/index.html
387-[NSMutableDictionary]: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSMutableDictionary_Class/index.html
388-[-setObject:forKey:]: http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSMutableDictionary_Class/Reference/Reference.html#//apple_ref/occ/instm/NSMutableDictionary/setObject:forKey:
389-[-removeObjectForKey:]: http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSMutableDictionary_Class/Reference/Reference.html#//apple_ref/occ/instm/NSMutableDictionary/removeObjectForKey:
390-[NSData]: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSData_Class/index.html
391-[NSFastEnumeration]: http://developer.apple.com/library/mac/documentation/Cocoa/Reference/NSFastEnumeration_protocol/Reference/NSFastEnumeration.html
392-[NSString]: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/index.html
393-[printf]: http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/printf.3.html
394-[memmove]: http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/memmove.3.html
395
396=== removed file 'Dependencies/JSONKit/JSONKit.h'
397--- Dependencies/JSONKit/JSONKit.h 2011-08-31 14:56:30 +0000
398+++ Dependencies/JSONKit/JSONKit.h 1970-01-01 00:00:00 +0000
399@@ -1,251 +0,0 @@
400-//
401-// JSONKit.h
402-// http://github.com/johnezang/JSONKit
403-// Dual licensed under either the terms of the BSD License, or alternatively
404-// under the terms of the Apache License, Version 2.0, as specified below.
405-//
406-
407-/*
408- Copyright (c) 2011, John Engelhart
409-
410- All rights reserved.
411-
412- Redistribution and use in source and binary forms, with or without
413- modification, are permitted provided that the following conditions are met:
414-
415- * Redistributions of source code must retain the above copyright
416- notice, this list of conditions and the following disclaimer.
417-
418- * Redistributions in binary form must reproduce the above copyright
419- notice, this list of conditions and the following disclaimer in the
420- documentation and/or other materials provided with the distribution.
421-
422- * Neither the name of the Zang Industries nor the names of its
423- contributors may be used to endorse or promote products derived from
424- this software without specific prior written permission.
425-
426- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
427- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
428- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
429- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
430- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
431- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
432- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
433- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
434- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
435- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
436- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
437-*/
438-
439-/*
440- Copyright 2011 John Engelhart
441-
442- Licensed under the Apache License, Version 2.0 (the "License");
443- you may not use this file except in compliance with the License.
444- You may obtain a copy of the License at
445-
446- http://www.apache.org/licenses/LICENSE-2.0
447-
448- Unless required by applicable law or agreed to in writing, software
449- distributed under the License is distributed on an "AS IS" BASIS,
450- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
451- See the License for the specific language governing permissions and
452- limitations under the License.
453-*/
454-
455-#include <stddef.h>
456-#include <stdint.h>
457-#include <limits.h>
458-#include <TargetConditionals.h>
459-#include <AvailabilityMacros.h>
460-
461-#ifdef __OBJC__
462-#import <Foundation/NSArray.h>
463-#import <Foundation/NSData.h>
464-#import <Foundation/NSDictionary.h>
465-#import <Foundation/NSError.h>
466-#import <Foundation/NSObjCRuntime.h>
467-#import <Foundation/NSString.h>
468-#endif // __OBJC__
469-
470-#ifdef __cplusplus
471-extern "C" {
472-#endif
473-
474-
475-// For Mac OS X < 10.5.
476-#ifndef NSINTEGER_DEFINED
477-#define NSINTEGER_DEFINED
478-#if defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
479-typedef long NSInteger;
480-typedef unsigned long NSUInteger;
481-#define NSIntegerMin LONG_MIN
482-#define NSIntegerMax LONG_MAX
483-#define NSUIntegerMax ULONG_MAX
484-#else // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
485-typedef int NSInteger;
486-typedef unsigned int NSUInteger;
487-#define NSIntegerMin INT_MIN
488-#define NSIntegerMax INT_MAX
489-#define NSUIntegerMax UINT_MAX
490-#endif // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
491-#endif // NSINTEGER_DEFINED
492-
493-
494-#ifndef _JSONKIT_H_
495-#define _JSONKIT_H_
496-
497-#if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__APPLE_CC__) && (__APPLE_CC__ >= 5465)
498-#define JK_DEPRECATED_ATTRIBUTE __attribute__((deprecated))
499-#else
500-#define JK_DEPRECATED_ATTRIBUTE
501-#endif
502-
503-#define JSONKIT_VERSION_MAJOR 1
504-#define JSONKIT_VERSION_MINOR 4
505-
506-typedef NSUInteger JKFlags;
507-
508-/*
509- JKParseOptionComments : Allow C style // and /_* ... *_/ (without a _, obviously) comments in JSON.
510- JKParseOptionUnicodeNewlines : Allow Unicode recommended (?:\r\n|[\n\v\f\r\x85\p{Zl}\p{Zp}]) newlines.
511- JKParseOptionLooseUnicode : Normally the decoder will stop with an error at any malformed Unicode.
512- This option allows JSON with malformed Unicode to be parsed without reporting an error.
513- Any malformed Unicode is replaced with \uFFFD, or "REPLACEMENT CHARACTER".
514- */
515-
516-enum {
517- JKParseOptionNone = 0,
518- JKParseOptionStrict = 0,
519- JKParseOptionComments = (1 << 0),
520- JKParseOptionUnicodeNewlines = (1 << 1),
521- JKParseOptionLooseUnicode = (1 << 2),
522- JKParseOptionPermitTextAfterValidJSON = (1 << 3),
523- JKParseOptionValidFlags = (JKParseOptionComments | JKParseOptionUnicodeNewlines | JKParseOptionLooseUnicode | JKParseOptionPermitTextAfterValidJSON),
524-};
525-typedef JKFlags JKParseOptionFlags;
526-
527-enum {
528- JKSerializeOptionNone = 0,
529- JKSerializeOptionPretty = (1 << 0),
530- JKSerializeOptionEscapeUnicode = (1 << 1),
531- JKSerializeOptionEscapeForwardSlashes = (1 << 4),
532- JKSerializeOptionValidFlags = (JKSerializeOptionPretty | JKSerializeOptionEscapeUnicode | JKSerializeOptionEscapeForwardSlashes),
533-};
534-typedef JKFlags JKSerializeOptionFlags;
535-
536-#ifdef __OBJC__
537-
538-typedef struct JKParseState JKParseState; // Opaque internal, private type.
539-
540-// As a general rule of thumb, if you use a method that doesn't accept a JKParseOptionFlags argument, it defaults to JKParseOptionStrict
541-
542-@interface JSONDecoder : NSObject {
543- JKParseState *parseState;
544-}
545-+ (id)decoder;
546-+ (id)decoderWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
547-- (id)initWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
548-- (void)clearCache;
549-
550-// The parse... methods were deprecated in v1.4 in favor of the v1.4 objectWith... methods.
551-- (id)parseUTF8String:(const unsigned char *)string length:(size_t)length JK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithUTF8String:length: instead.
552-- (id)parseUTF8String:(const unsigned char *)string length:(size_t)length error:(NSError **)error JK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithUTF8String:length:error: instead.
553-// The NSData MUST be UTF8 encoded JSON.
554-- (id)parseJSONData:(NSData *)jsonData JK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithData: instead.
555-- (id)parseJSONData:(NSData *)jsonData error:(NSError **)error JK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithData:error: instead.
556-
557-// Methods that return immutable collection objects.
558-- (id)objectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length;
559-- (id)objectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length error:(NSError **)error;
560-// The NSData MUST be UTF8 encoded JSON.
561-- (id)objectWithData:(NSData *)jsonData;
562-- (id)objectWithData:(NSData *)jsonData error:(NSError **)error;
563-
564-// Methods that return mutable collection objects.
565-- (id)mutableObjectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length;
566-- (id)mutableObjectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length error:(NSError **)error;
567-// The NSData MUST be UTF8 encoded JSON.
568-- (id)mutableObjectWithData:(NSData *)jsonData;
569-- (id)mutableObjectWithData:(NSData *)jsonData error:(NSError **)error;
570-
571-@end
572-
573-////////////
574-#pragma mark Deserializing methods
575-////////////
576-
577-@interface NSString (JSONKitDeserializing)
578-- (id)objectFromJSONString;
579-- (id)objectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
580-- (id)objectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error;
581-- (id)mutableObjectFromJSONString;
582-- (id)mutableObjectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
583-- (id)mutableObjectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error;
584-@end
585-
586-@interface NSData (JSONKitDeserializing)
587-// The NSData MUST be UTF8 encoded JSON.
588-- (id)objectFromJSONData;
589-- (id)objectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
590-- (id)objectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error;
591-- (id)mutableObjectFromJSONData;
592-- (id)mutableObjectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
593-- (id)mutableObjectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error;
594-@end
595-
596-////////////
597-#pragma mark Serializing methods
598-////////////
599-
600-@interface NSString (JSONKitSerializing)
601-// Convenience methods for those that need to serialize the receiving NSString (i.e., instead of having to serialize a NSArray with a single NSString, you can "serialize to JSON" just the NSString).
602-// Normally, a string that is serialized to JSON has quotation marks surrounding it, which you may or may not want when serializing a single string, and can be controlled with includeQuotes:
603-// includeQuotes:YES `a "test"...` -> `"a \"test\"..."`
604-// includeQuotes:NO `a "test"...` -> `a \"test\"...`
605-- (NSData *)JSONData; // Invokes JSONDataWithOptions:JKSerializeOptionNone includeQuotes:YES
606-- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions includeQuotes:(BOOL)includeQuotes error:(NSError **)error;
607-- (NSString *)JSONString; // Invokes JSONStringWithOptions:JKSerializeOptionNone includeQuotes:YES
608-- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions includeQuotes:(BOOL)includeQuotes error:(NSError **)error;
609-@end
610-
611-@interface NSArray (JSONKitSerializing)
612-- (NSData *)JSONData;
613-- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error;
614-- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error;
615-- (NSString *)JSONString;
616-- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error;
617-- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error;
618-@end
619-
620-@interface NSDictionary (JSONKitSerializing)
621-- (NSData *)JSONData;
622-- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error;
623-- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error;
624-- (NSString *)JSONString;
625-- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error;
626-- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error;
627-@end
628-
629-#ifdef __BLOCKS__
630-
631-@interface NSArray (JSONKitSerializingBlockAdditions)
632-- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error;
633-- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error;
634-@end
635-
636-@interface NSDictionary (JSONKitSerializingBlockAdditions)
637-- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error;
638-- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error;
639-@end
640-
641-#endif
642-
643-
644-#endif // __OBJC__
645-
646-#endif // _JSONKIT_H_
647-
648-#ifdef __cplusplus
649-} // extern "C"
650-#endif
651
652=== removed file 'Dependencies/JSONKit/JSONKit.m'
653--- Dependencies/JSONKit/JSONKit.m 2011-08-31 14:56:30 +0000
654+++ Dependencies/JSONKit/JSONKit.m 1970-01-01 00:00:00 +0000
655@@ -1,3022 +0,0 @@
656-//
657-// JSONKit.m
658-// http://github.com/johnezang/JSONKit
659-// Dual licensed under either the terms of the BSD License, or alternatively
660-// under the terms of the Apache License, Version 2.0, as specified below.
661-//
662-
663-/*
664- Copyright (c) 2011, John Engelhart
665-
666- All rights reserved.
667-
668- Redistribution and use in source and binary forms, with or without
669- modification, are permitted provided that the following conditions are met:
670-
671- * Redistributions of source code must retain the above copyright
672- notice, this list of conditions and the following disclaimer.
673-
674- * Redistributions in binary form must reproduce the above copyright
675- notice, this list of conditions and the following disclaimer in the
676- documentation and/or other materials provided with the distribution.
677-
678- * Neither the name of the Zang Industries nor the names of its
679- contributors may be used to endorse or promote products derived from
680- this software without specific prior written permission.
681-
682- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
683- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
684- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
685- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
686- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
687- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
688- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
689- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
690- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
691- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
692- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
693-*/
694-
695-/*
696- Copyright 2011 John Engelhart
697-
698- Licensed under the Apache License, Version 2.0 (the "License");
699- you may not use this file except in compliance with the License.
700- You may obtain a copy of the License at
701-
702- http://www.apache.org/licenses/LICENSE-2.0
703-
704- Unless required by applicable law or agreed to in writing, software
705- distributed under the License is distributed on an "AS IS" BASIS,
706- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
707- See the License for the specific language governing permissions and
708- limitations under the License.
709-*/
710-
711-
712-/*
713- Acknowledgments:
714-
715- The bulk of the UTF8 / UTF32 conversion and verification comes
716- from ConvertUTF.[hc]. It has been modified from the original sources.
717-
718- The original sources were obtained from http://www.unicode.org/.
719- However, the web site no longer seems to host the files. Instead,
720- the Unicode FAQ http://www.unicode.org/faq//utf_bom.html#gen4
721- points to International Components for Unicode (ICU)
722- http://site.icu-project.org/ as an example of how to write a UTF
723- converter.
724-
725- The decision to use the ConvertUTF.[ch] code was made to leverage
726- "proven" code. Hopefully the local modifications are bug free.
727-
728- The code in isValidCodePoint() is derived from the ICU code in
729- utf.h for the macros U_IS_UNICODE_NONCHAR and U_IS_UNICODE_CHAR.
730-
731- From the original ConvertUTF.[ch]:
732-
733- * Copyright 2001-2004 Unicode, Inc.
734- *
735- * Disclaimer
736- *
737- * This source code is provided as is by Unicode, Inc. No claims are
738- * made as to fitness for any particular purpose. No warranties of any
739- * kind are expressed or implied. The recipient agrees to determine
740- * applicability of information provided. If this file has been
741- * purchased on magnetic or optical media from Unicode, Inc., the
742- * sole remedy for any claim will be exchange of defective media
743- * within 90 days of receipt.
744- *
745- * Limitations on Rights to Redistribute This Code
746- *
747- * Unicode, Inc. hereby grants the right to freely use the information
748- * supplied in this file in the creation of products supporting the
749- * Unicode Standard, and to make copies of this file in any form
750- * for internal or external distribution as long as this notice
751- * remains attached.
752-
753-*/
754-
755-#include <stdio.h>
756-#include <stdlib.h>
757-#include <stdint.h>
758-#include <string.h>
759-#include <assert.h>
760-#include <sys/errno.h>
761-#include <math.h>
762-#include <limits.h>
763-#include <objc/runtime.h>
764-
765-#import "JSONKit.h"
766-
767-//#include <CoreFoundation/CoreFoundation.h>
768-#include <CoreFoundation/CFString.h>
769-#include <CoreFoundation/CFArray.h>
770-#include <CoreFoundation/CFDictionary.h>
771-#include <CoreFoundation/CFNumber.h>
772-
773-//#import <Foundation/Foundation.h>
774-#import <Foundation/NSArray.h>
775-#import <Foundation/NSAutoreleasePool.h>
776-#import <Foundation/NSData.h>
777-#import <Foundation/NSDictionary.h>
778-#import <Foundation/NSException.h>
779-#import <Foundation/NSNull.h>
780-#import <Foundation/NSObjCRuntime.h>
781-
782-#ifndef __has_feature
783-#define __has_feature(x) 0
784-#endif
785-
786-#ifdef JK_ENABLE_CF_TRANSFER_OWNERSHIP_CALLBACKS
787-#warning As of JSONKit v1.4, JK_ENABLE_CF_TRANSFER_OWNERSHIP_CALLBACKS is no longer required. It is no longer a valid option.
788-#endif
789-
790-#ifdef __OBJC_GC__
791-#error JSONKit does not support Objective-C Garbage Collection
792-#endif
793-
794-#if __has_feature(objc_arc)
795-#error JSONKit does not support Objective-C Automatic Reference Counting (ARC)
796-#endif
797-
798-// The following checks are really nothing more than sanity checks.
799-// JSONKit technically has a few problems from a "strictly C99 conforming" standpoint, though they are of the pedantic nitpicking variety.
800-// In practice, though, for the compilers and architectures we can reasonably expect this code to be compiled for, these pedantic nitpicks aren't really a problem.
801-// Since we're limited as to what we can do with pre-processor #if checks, these checks are not nearly as through as they should be.
802-
803-#if (UINT_MAX != 0xffffffffU) || (INT_MIN != (-0x7fffffff-1)) || (ULLONG_MAX != 0xffffffffffffffffULL) || (LLONG_MIN != (-0x7fffffffffffffffLL-1LL))
804-#error JSONKit requires the C 'int' and 'long long' types to be 32 and 64 bits respectively.
805-#endif
806-
807-#if !defined(__LP64__) && ((UINT_MAX != ULONG_MAX) || (INT_MAX != LONG_MAX) || (INT_MIN != LONG_MIN) || (WORD_BIT != LONG_BIT))
808-#error JSONKit requires the C 'int' and 'long' types to be the same on 32-bit architectures.
809-#endif
810-
811-// Cocoa / Foundation uses NS*Integer as the type for a lot of arguments. We make sure that NS*Integer is something we are expecting and is reasonably compatible with size_t / ssize_t
812-
813-#if (NSUIntegerMax != ULONG_MAX) || (NSIntegerMax != LONG_MAX) || (NSIntegerMin != LONG_MIN)
814-#error JSONKit requires NSInteger and NSUInteger to be the same size as the C 'long' type.
815-#endif
816-
817-#if (NSUIntegerMax != SIZE_MAX) || (NSIntegerMax != SSIZE_MAX)
818-#error JSONKit requires NSInteger and NSUInteger to be the same size as the C 'size_t' type.
819-#endif
820-
821-
822-// For DJB hash.
823-#define JK_HASH_INIT (1402737925UL)
824-
825-// Use __builtin_clz() instead of trailingBytesForUTF8[] table lookup.
826-#define JK_FAST_TRAILING_BYTES
827-
828-// JK_CACHE_SLOTS must be a power of 2. Default size is 1024 slots.
829-#define JK_CACHE_SLOTS_BITS (10)
830-#define JK_CACHE_SLOTS (1UL << JK_CACHE_SLOTS_BITS)
831-// JK_CACHE_PROBES is the number of probe attempts.
832-#define JK_CACHE_PROBES (4UL)
833-// JK_INIT_CACHE_AGE must be (1 << AGE) - 1
834-#define JK_INIT_CACHE_AGE (0)
835-
836-// JK_TOKENBUFFER_SIZE is the default stack size for the temporary buffer used to hold "non-simple" strings (i.e., contains \ escapes)
837-#define JK_TOKENBUFFER_SIZE (1024UL * 2UL)
838-
839-// JK_STACK_OBJS is the default number of spaces reserved on the stack for temporarily storing pointers to Obj-C objects before they can be transferred to a NSArray / NSDictionary.
840-#define JK_STACK_OBJS (1024UL * 1UL)
841-
842-#define JK_JSONBUFFER_SIZE (1024UL * 4UL)
843-#define JK_UTF8BUFFER_SIZE (1024UL * 16UL)
844-
845-#define JK_ENCODE_CACHE_SLOTS (1024UL)
846-
847-
848-#if defined (__GNUC__) && (__GNUC__ >= 4)
849-#define JK_ATTRIBUTES(attr, ...) __attribute__((attr, ##__VA_ARGS__))
850-#define JK_EXPECTED(cond, expect) __builtin_expect((long)(cond), (expect))
851-#define JK_EXPECT_T(cond) JK_EXPECTED(cond, 1U)
852-#define JK_EXPECT_F(cond) JK_EXPECTED(cond, 0U)
853-#define JK_PREFETCH(ptr) __builtin_prefetch(ptr)
854-#else // defined (__GNUC__) && (__GNUC__ >= 4)
855-#define JK_ATTRIBUTES(attr, ...)
856-#define JK_EXPECTED(cond, expect) (cond)
857-#define JK_EXPECT_T(cond) (cond)
858-#define JK_EXPECT_F(cond) (cond)
859-#define JK_PREFETCH(ptr)
860-#endif // defined (__GNUC__) && (__GNUC__ >= 4)
861-
862-#define JK_STATIC_INLINE static __inline__ JK_ATTRIBUTES(always_inline)
863-#define JK_ALIGNED(arg) JK_ATTRIBUTES(aligned(arg))
864-#define JK_UNUSED_ARG JK_ATTRIBUTES(unused)
865-#define JK_WARN_UNUSED JK_ATTRIBUTES(warn_unused_result)
866-#define JK_WARN_UNUSED_CONST JK_ATTRIBUTES(warn_unused_result, const)
867-#define JK_WARN_UNUSED_PURE JK_ATTRIBUTES(warn_unused_result, pure)
868-#define JK_WARN_UNUSED_SENTINEL JK_ATTRIBUTES(warn_unused_result, sentinel)
869-#define JK_NONNULL_ARGS(arg, ...) JK_ATTRIBUTES(nonnull(arg, ##__VA_ARGS__))
870-#define JK_WARN_UNUSED_NONNULL_ARGS(arg, ...) JK_ATTRIBUTES(warn_unused_result, nonnull(arg, ##__VA_ARGS__))
871-#define JK_WARN_UNUSED_CONST_NONNULL_ARGS(arg, ...) JK_ATTRIBUTES(warn_unused_result, const, nonnull(arg, ##__VA_ARGS__))
872-#define JK_WARN_UNUSED_PURE_NONNULL_ARGS(arg, ...) JK_ATTRIBUTES(warn_unused_result, pure, nonnull(arg, ##__VA_ARGS__))
873-
874-#if defined (__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3)
875-#define JK_ALLOC_SIZE_NON_NULL_ARGS_WARN_UNUSED(as, nn, ...) JK_ATTRIBUTES(warn_unused_result, nonnull(nn, ##__VA_ARGS__), alloc_size(as))
876-#else // defined (__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3)
877-#define JK_ALLOC_SIZE_NON_NULL_ARGS_WARN_UNUSED(as, nn, ...) JK_ATTRIBUTES(warn_unused_result, nonnull(nn, ##__VA_ARGS__))
878-#endif // defined (__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3)
879-
880-
881-@class JKArray, JKDictionaryEnumerator, JKDictionary;
882-
883-enum {
884- JSONNumberStateStart = 0,
885- JSONNumberStateFinished = 1,
886- JSONNumberStateError = 2,
887- JSONNumberStateWholeNumberStart = 3,
888- JSONNumberStateWholeNumberMinus = 4,
889- JSONNumberStateWholeNumberZero = 5,
890- JSONNumberStateWholeNumber = 6,
891- JSONNumberStatePeriod = 7,
892- JSONNumberStateFractionalNumberStart = 8,
893- JSONNumberStateFractionalNumber = 9,
894- JSONNumberStateExponentStart = 10,
895- JSONNumberStateExponentPlusMinus = 11,
896- JSONNumberStateExponent = 12,
897-};
898-
899-enum {
900- JSONStringStateStart = 0,
901- JSONStringStateParsing = 1,
902- JSONStringStateFinished = 2,
903- JSONStringStateError = 3,
904- JSONStringStateEscape = 4,
905- JSONStringStateEscapedUnicode1 = 5,
906- JSONStringStateEscapedUnicode2 = 6,
907- JSONStringStateEscapedUnicode3 = 7,
908- JSONStringStateEscapedUnicode4 = 8,
909- JSONStringStateEscapedUnicodeSurrogate1 = 9,
910- JSONStringStateEscapedUnicodeSurrogate2 = 10,
911- JSONStringStateEscapedUnicodeSurrogate3 = 11,
912- JSONStringStateEscapedUnicodeSurrogate4 = 12,
913- JSONStringStateEscapedNeedEscapeForSurrogate = 13,
914- JSONStringStateEscapedNeedEscapedUForSurrogate = 14,
915-};
916-
917-enum {
918- JKParseAcceptValue = (1 << 0),
919- JKParseAcceptComma = (1 << 1),
920- JKParseAcceptEnd = (1 << 2),
921- JKParseAcceptValueOrEnd = (JKParseAcceptValue | JKParseAcceptEnd),
922- JKParseAcceptCommaOrEnd = (JKParseAcceptComma | JKParseAcceptEnd),
923-};
924-
925-enum {
926- JKClassUnknown = 0,
927- JKClassString = 1,
928- JKClassNumber = 2,
929- JKClassArray = 3,
930- JKClassDictionary = 4,
931- JKClassNull = 5,
932-};
933-
934-enum {
935- JKManagedBufferOnStack = 1,
936- JKManagedBufferOnHeap = 2,
937- JKManagedBufferLocationMask = (0x3),
938- JKManagedBufferLocationShift = (0),
939-
940- JKManagedBufferMustFree = (1 << 2),
941-};
942-typedef JKFlags JKManagedBufferFlags;
943-
944-enum {
945- JKObjectStackOnStack = 1,
946- JKObjectStackOnHeap = 2,
947- JKObjectStackLocationMask = (0x3),
948- JKObjectStackLocationShift = (0),
949-
950- JKObjectStackMustFree = (1 << 2),
951-};
952-typedef JKFlags JKObjectStackFlags;
953-
954-enum {
955- JKTokenTypeInvalid = 0,
956- JKTokenTypeNumber = 1,
957- JKTokenTypeString = 2,
958- JKTokenTypeObjectBegin = 3,
959- JKTokenTypeObjectEnd = 4,
960- JKTokenTypeArrayBegin = 5,
961- JKTokenTypeArrayEnd = 6,
962- JKTokenTypeSeparator = 7,
963- JKTokenTypeComma = 8,
964- JKTokenTypeTrue = 9,
965- JKTokenTypeFalse = 10,
966- JKTokenTypeNull = 11,
967- JKTokenTypeWhiteSpace = 12,
968-};
969-typedef NSUInteger JKTokenType;
970-
971-// These are prime numbers to assist with hash slot probing.
972-enum {
973- JKValueTypeNone = 0,
974- JKValueTypeString = 5,
975- JKValueTypeLongLong = 7,
976- JKValueTypeUnsignedLongLong = 11,
977- JKValueTypeDouble = 13,
978-};
979-typedef NSUInteger JKValueType;
980-
981-enum {
982- JKEncodeOptionAsData = 1,
983- JKEncodeOptionAsString = 2,
984- JKEncodeOptionAsTypeMask = 0x7,
985- JKEncodeOptionCollectionObj = (1 << 3),
986- JKEncodeOptionStringObj = (1 << 4),
987- JKEncodeOptionStringObjTrimQuotes = (1 << 5),
988-
989-};
990-typedef NSUInteger JKEncodeOptionType;
991-
992-typedef NSUInteger JKHash;
993-
994-typedef struct JKTokenCacheItem JKTokenCacheItem;
995-typedef struct JKTokenCache JKTokenCache;
996-typedef struct JKTokenValue JKTokenValue;
997-typedef struct JKParseToken JKParseToken;
998-typedef struct JKPtrRange JKPtrRange;
999-typedef struct JKObjectStack JKObjectStack;
1000-typedef struct JKBuffer JKBuffer;
1001-typedef struct JKConstBuffer JKConstBuffer;
1002-typedef struct JKConstPtrRange JKConstPtrRange;
1003-typedef struct JKRange JKRange;
1004-typedef struct JKManagedBuffer JKManagedBuffer;
1005-typedef struct JKFastClassLookup JKFastClassLookup;
1006-typedef struct JKEncodeCache JKEncodeCache;
1007-typedef struct JKEncodeState JKEncodeState;
1008-typedef struct JKObjCImpCache JKObjCImpCache;
1009-typedef struct JKHashTableEntry JKHashTableEntry;
1010-
1011-typedef id (*NSNumberAllocImp)(id receiver, SEL selector);
1012-typedef id (*NSNumberInitWithUnsignedLongLongImp)(id receiver, SEL selector, unsigned long long value);
1013-typedef id (*JKClassFormatterIMP)(id receiver, SEL selector, id object);
1014-#ifdef __BLOCKS__
1015-typedef id (^JKClassFormatterBlock)(id formatObject);
1016-#endif
1017-
1018-
1019-struct JKPtrRange {
1020- unsigned char *ptr;
1021- size_t length;
1022-};
1023-
1024-struct JKConstPtrRange {
1025- const unsigned char *ptr;
1026- size_t length;
1027-};
1028-
1029-struct JKRange {
1030- size_t location, length;
1031-};
1032-
1033-struct JKManagedBuffer {
1034- JKPtrRange bytes;
1035- JKManagedBufferFlags flags;
1036- size_t roundSizeUpToMultipleOf;
1037-};
1038-
1039-struct JKObjectStack {
1040- void **objects, **keys;
1041- CFHashCode *cfHashes;
1042- size_t count, index, roundSizeUpToMultipleOf;
1043- JKObjectStackFlags flags;
1044-};
1045-
1046-struct JKBuffer {
1047- JKPtrRange bytes;
1048-};
1049-
1050-struct JKConstBuffer {
1051- JKConstPtrRange bytes;
1052-};
1053-
1054-struct JKTokenValue {
1055- JKConstPtrRange ptrRange;
1056- JKValueType type;
1057- JKHash hash;
1058- union {
1059- long long longLongValue;
1060- unsigned long long unsignedLongLongValue;
1061- double doubleValue;
1062- } number;
1063- JKTokenCacheItem *cacheItem;
1064-};
1065-
1066-struct JKParseToken {
1067- JKConstPtrRange tokenPtrRange;
1068- JKTokenType type;
1069- JKTokenValue value;
1070- JKManagedBuffer tokenBuffer;
1071-};
1072-
1073-struct JKTokenCacheItem {
1074- void *object;
1075- JKHash hash;
1076- CFHashCode cfHash;
1077- size_t size;
1078- unsigned char *bytes;
1079- JKValueType type;
1080-};
1081-
1082-struct JKTokenCache {
1083- JKTokenCacheItem *items;
1084- size_t count;
1085- unsigned int prng_lfsr;
1086- unsigned char age[JK_CACHE_SLOTS];
1087-};
1088-
1089-struct JKObjCImpCache {
1090- Class NSNumberClass;
1091- NSNumberAllocImp NSNumberAlloc;
1092- NSNumberInitWithUnsignedLongLongImp NSNumberInitWithUnsignedLongLong;
1093-};
1094-
1095-struct JKParseState {
1096- JKParseOptionFlags parseOptionFlags;
1097- JKConstBuffer stringBuffer;
1098- size_t atIndex, lineNumber, lineStartIndex;
1099- size_t prev_atIndex, prev_lineNumber, prev_lineStartIndex;
1100- JKParseToken token;
1101- JKObjectStack objectStack;
1102- JKTokenCache cache;
1103- JKObjCImpCache objCImpCache;
1104- NSError *error;
1105- int errorIsPrev;
1106- BOOL mutableCollections;
1107-};
1108-
1109-struct JKFastClassLookup {
1110- void *stringClass;
1111- void *numberClass;
1112- void *arrayClass;
1113- void *dictionaryClass;
1114- void *nullClass;
1115-};
1116-
1117-struct JKEncodeCache {
1118- id object;
1119- size_t offset;
1120- size_t length;
1121-};
1122-
1123-struct JKEncodeState {
1124- JKManagedBuffer utf8ConversionBuffer;
1125- JKManagedBuffer stringBuffer;
1126- size_t atIndex;
1127- JKFastClassLookup fastClassLookup;
1128- JKEncodeCache cache[JK_ENCODE_CACHE_SLOTS];
1129- JKSerializeOptionFlags serializeOptionFlags;
1130- JKEncodeOptionType encodeOption;
1131- size_t depth;
1132- NSError *error;
1133- id classFormatterDelegate;
1134- SEL classFormatterSelector;
1135- JKClassFormatterIMP classFormatterIMP;
1136-#ifdef __BLOCKS__
1137- JKClassFormatterBlock classFormatterBlock;
1138-#endif
1139-};
1140-
1141-// This is a JSONKit private class.
1142-@interface JKSerializer : NSObject {
1143- JKEncodeState *encodeState;
1144-}
1145-
1146-#ifdef __BLOCKS__
1147-#define JKSERIALIZER_BLOCKS_PROTO id(^)(id object)
1148-#else
1149-#define JKSERIALIZER_BLOCKS_PROTO id
1150-#endif
1151-
1152-+ (id)serializeObject:(id)object options:(JKSerializeOptionFlags)optionFlags encodeOption:(JKEncodeOptionType)encodeOption block:(JKSERIALIZER_BLOCKS_PROTO)block delegate:(id)delegate selector:(SEL)selector error:(NSError **)error;
1153-- (id)serializeObject:(id)object options:(JKSerializeOptionFlags)optionFlags encodeOption:(JKEncodeOptionType)encodeOption block:(JKSERIALIZER_BLOCKS_PROTO)block delegate:(id)delegate selector:(SEL)selector error:(NSError **)error;
1154-- (void)releaseState;
1155-
1156-@end
1157-
1158-struct JKHashTableEntry {
1159- NSUInteger keyHash;
1160- id key, object;
1161-};
1162-
1163-
1164-typedef uint32_t UTF32; /* at least 32 bits */
1165-typedef uint16_t UTF16; /* at least 16 bits */
1166-typedef uint8_t UTF8; /* typically 8 bits */
1167-
1168-typedef enum {
1169- conversionOK, /* conversion successful */
1170- sourceExhausted, /* partial character in source, but hit end */
1171- targetExhausted, /* insuff. room in target for conversion */
1172- sourceIllegal /* source sequence is illegal/malformed */
1173-} ConversionResult;
1174-
1175-#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
1176-#define UNI_MAX_BMP (UTF32)0x0000FFFF
1177-#define UNI_MAX_UTF16 (UTF32)0x0010FFFF
1178-#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF
1179-#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF
1180-#define UNI_SUR_HIGH_START (UTF32)0xD800
1181-#define UNI_SUR_HIGH_END (UTF32)0xDBFF
1182-#define UNI_SUR_LOW_START (UTF32)0xDC00
1183-#define UNI_SUR_LOW_END (UTF32)0xDFFF
1184-
1185-
1186-#if !defined(JK_FAST_TRAILING_BYTES)
1187-static const char trailingBytesForUTF8[256] = {
1188- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1189- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1190- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1191- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1192- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1193- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1194- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1195- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5
1196-};
1197-#endif
1198-
1199-static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, 0x03C82080UL, 0xFA082080UL, 0x82082080UL };
1200-static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
1201-
1202-#define JK_AT_STRING_PTR(x) (&((x)->stringBuffer.bytes.ptr[(x)->atIndex]))
1203-#define JK_END_STRING_PTR(x) (&((x)->stringBuffer.bytes.ptr[(x)->stringBuffer.bytes.length]))
1204-
1205-
1206-static JKArray *_JKArrayCreate(id *objects, NSUInteger count, BOOL mutableCollection);
1207-static void _JKArrayInsertObjectAtIndex(JKArray *array, id newObject, NSUInteger objectIndex);
1208-static void _JKArrayReplaceObjectAtIndexWithObject(JKArray *array, NSUInteger objectIndex, id newObject);
1209-static void _JKArrayRemoveObjectAtIndex(JKArray *array, NSUInteger objectIndex);
1210-
1211-
1212-static NSUInteger _JKDictionaryCapacityForCount(NSUInteger count);
1213-static JKDictionary *_JKDictionaryCreate(id *keys, NSUInteger *keyHashes, id *objects, NSUInteger count, BOOL mutableCollection);
1214-static JKHashTableEntry *_JKDictionaryHashEntry(JKDictionary *dictionary);
1215-static NSUInteger _JKDictionaryCapacity(JKDictionary *dictionary);
1216-static void _JKDictionaryResizeIfNeccessary(JKDictionary *dictionary);
1217-static void _JKDictionaryRemoveObjectWithEntry(JKDictionary *dictionary, JKHashTableEntry *entry);
1218-static void _JKDictionaryAddObject(JKDictionary *dictionary, NSUInteger keyHash, id key, id object);
1219-static JKHashTableEntry *_JKDictionaryHashTableEntryForKey(JKDictionary *dictionary, id aKey);
1220-
1221-
1222-static void _JSONDecoderCleanup(JSONDecoder *decoder);
1223-
1224-static id _NSStringObjectFromJSONString(NSString *jsonString, JKParseOptionFlags parseOptionFlags, NSError **error, BOOL mutableCollection);
1225-
1226-
1227-static void jk_managedBuffer_release(JKManagedBuffer *managedBuffer);
1228-static void jk_managedBuffer_setToStackBuffer(JKManagedBuffer *managedBuffer, unsigned char *ptr, size_t length);
1229-static unsigned char *jk_managedBuffer_resize(JKManagedBuffer *managedBuffer, size_t newSize);
1230-static void jk_objectStack_release(JKObjectStack *objectStack);
1231-static void jk_objectStack_setToStackBuffer(JKObjectStack *objectStack, void **objects, void **keys, CFHashCode *cfHashes, size_t count);
1232-static int jk_objectStack_resize(JKObjectStack *objectStack, size_t newCount);
1233-
1234-static void jk_error(JKParseState *parseState, NSString *format, ...);
1235-static int jk_parse_string(JKParseState *parseState);
1236-static int jk_parse_number(JKParseState *parseState);
1237-static size_t jk_parse_is_newline(JKParseState *parseState, const unsigned char *atCharacterPtr);
1238-JK_STATIC_INLINE int jk_parse_skip_newline(JKParseState *parseState);
1239-JK_STATIC_INLINE void jk_parse_skip_whitespace(JKParseState *parseState);
1240-static int jk_parse_next_token(JKParseState *parseState);
1241-static void jk_error_parse_accept_or3(JKParseState *parseState, int state, NSString *or1String, NSString *or2String, NSString *or3String);
1242-static void *jk_create_dictionary(JKParseState *parseState, size_t startingObjectIndex);
1243-static void *jk_parse_dictionary(JKParseState *parseState);
1244-static void *jk_parse_array(JKParseState *parseState);
1245-static void *jk_object_for_token(JKParseState *parseState);
1246-static void *jk_cachedObjects(JKParseState *parseState);
1247-JK_STATIC_INLINE void jk_cache_age(JKParseState *parseState);
1248-JK_STATIC_INLINE void jk_set_parsed_token(JKParseState *parseState, const unsigned char *ptr, size_t length, JKTokenType type, size_t advanceBy);
1249-
1250-
1251-static void jk_encode_error(JKEncodeState *encodeState, NSString *format, ...);
1252-static int jk_encode_printf(JKEncodeState *encodeState, JKEncodeCache *cacheSlot, size_t startingAtIndex, id object, const char *format, ...);
1253-static int jk_encode_write(JKEncodeState *encodeState, JKEncodeCache *cacheSlot, size_t startingAtIndex, id object, const char *format);
1254-static int jk_encode_writePrettyPrintWhiteSpace(JKEncodeState *encodeState);
1255-static int jk_encode_write1slow(JKEncodeState *encodeState, ssize_t depthChange, const char *format);
1256-static int jk_encode_write1fast(JKEncodeState *encodeState, ssize_t depthChange JK_UNUSED_ARG, const char *format);
1257-static int jk_encode_writen(JKEncodeState *encodeState, JKEncodeCache *cacheSlot, size_t startingAtIndex, id object, const char *format, size_t length);
1258-JK_STATIC_INLINE JKHash jk_encode_object_hash(void *objectPtr);
1259-JK_STATIC_INLINE void jk_encode_updateCache(JKEncodeState *encodeState, JKEncodeCache *cacheSlot, size_t startingAtIndex, id object);
1260-static int jk_encode_add_atom_to_buffer(JKEncodeState *encodeState, void *objectPtr);
1261-
1262-#define jk_encode_write1(es, dc, f) (JK_EXPECT_F(_jk_encode_prettyPrint) ? jk_encode_write1slow(es, dc, f) : jk_encode_write1fast(es, dc, f))
1263-
1264-
1265-JK_STATIC_INLINE size_t jk_min(size_t a, size_t b);
1266-JK_STATIC_INLINE size_t jk_max(size_t a, size_t b);
1267-JK_STATIC_INLINE JKHash calculateHash(JKHash currentHash, unsigned char c);
1268-
1269-// JSONKit v1.4 used both a JKArray : NSArray and JKMutableArray : NSMutableArray, and the same for the dictionary collection type.
1270-// However, Louis Gerbarg (via cocoa-dev) pointed out that Cocoa / Core Foundation actually implements only a single class that inherits from the
1271-// mutable version, and keeps an ivar bit for whether or not that instance is mutable. This means that the immutable versions of the collection
1272-// classes receive the mutating methods, but this is handled by having those methods throw an exception when the ivar bit is set to immutable.
1273-// We adopt the same strategy here. It's both cleaner and gets rid of the method swizzling hackery used in JSONKit v1.4.
1274-
1275-
1276-// This is a workaround for issue #23 https://github.com/johnezang/JSONKit/pull/23
1277-// Basically, there seem to be a problem with using +load in static libraries on iOS. However, __attribute__ ((constructor)) does work correctly.
1278-// Since we do not require anything "special" that +load provides, and we can accomplish the same thing using __attribute__ ((constructor)), the +load logic was moved here.
1279-
1280-static Class _JKArrayClass = NULL;
1281-static size_t _JKArrayInstanceSize = 0UL;
1282-static Class _JKDictionaryClass = NULL;
1283-static size_t _JKDictionaryInstanceSize = 0UL;
1284-
1285-// For JSONDecoder...
1286-static Class _jk_NSNumberClass = NULL;
1287-static NSNumberAllocImp _jk_NSNumberAllocImp = NULL;
1288-static NSNumberInitWithUnsignedLongLongImp _jk_NSNumberInitWithUnsignedLongLongImp = NULL;
1289-
1290-extern void jk_collectionClassLoadTimeInitialization(void) __attribute__ ((constructor));
1291-
1292-void jk_collectionClassLoadTimeInitialization(void) {
1293- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // Though technically not required, the run time environment at load time initialization may be less than ideal.
1294-
1295- _JKArrayClass = objc_getClass("JKArray");
1296- _JKArrayInstanceSize = jk_max(16UL, class_getInstanceSize(_JKArrayClass));
1297-
1298- _JKDictionaryClass = objc_getClass("JKDictionary");
1299- _JKDictionaryInstanceSize = jk_max(16UL, class_getInstanceSize(_JKDictionaryClass));
1300-
1301- // For JSONDecoder...
1302- _jk_NSNumberClass = [NSNumber class];
1303- _jk_NSNumberAllocImp = (NSNumberAllocImp)[NSNumber methodForSelector:@selector(alloc)];
1304-
1305- // Hacktacular. Need to do it this way due to the nature of class clusters.
1306- id temp_NSNumber = [NSNumber alloc];
1307- _jk_NSNumberInitWithUnsignedLongLongImp = (NSNumberInitWithUnsignedLongLongImp)[temp_NSNumber methodForSelector:@selector(initWithUnsignedLongLong:)];
1308- [[temp_NSNumber init] release];
1309- temp_NSNumber = NULL;
1310-
1311- [pool release]; pool = NULL;
1312-}
1313-
1314-
1315-#pragma mark -
1316-@interface JKArray : NSMutableArray <NSCopying, NSMutableCopying, NSFastEnumeration> {
1317- id *objects;
1318- NSUInteger count, capacity, mutations;
1319-}
1320-@end
1321-
1322-@implementation JKArray
1323-
1324-+ (id)allocWithZone:(NSZone *)zone
1325-{
1326-#pragma unused(zone)
1327- [NSException raise:NSInvalidArgumentException format:@"*** - [%@ %@]: The %@ class is private to JSONKit and should not be used in this fashion.", NSStringFromClass([self class]), NSStringFromSelector(_cmd), NSStringFromClass([self class])];
1328- return(NULL);
1329-}
1330-
1331-static JKArray *_JKArrayCreate(id *objects, NSUInteger count, BOOL mutableCollection) {
1332- NSCParameterAssert((objects != NULL) && (_JKArrayClass != NULL) && (_JKArrayInstanceSize > 0UL));
1333- JKArray *array = NULL;
1334- if(JK_EXPECT_T((array = (JKArray *)calloc(1UL, _JKArrayInstanceSize)) != NULL)) { // Directly allocate the JKArray instance via calloc.
1335- array->isa = _JKArrayClass;
1336- if((array = [array init]) == NULL) { return(NULL); }
1337- array->capacity = count;
1338- array->count = count;
1339- if(JK_EXPECT_F((array->objects = (id *)malloc(sizeof(id) * array->capacity)) == NULL)) { [array autorelease]; return(NULL); }
1340- memcpy(array->objects, objects, array->capacity * sizeof(id));
1341- array->mutations = (mutableCollection == NO) ? 0UL : 1UL;
1342- }
1343- return(array);
1344-}
1345-
1346-// Note: The caller is responsible for -retaining the object that is to be added.
1347-static void _JKArrayInsertObjectAtIndex(JKArray *array, id newObject, NSUInteger objectIndex) {
1348- NSCParameterAssert((array != NULL) && (array->objects != NULL) && (array->count <= array->capacity) && (objectIndex <= array->count) && (newObject != NULL));
1349- if(!((array != NULL) && (array->objects != NULL) && (objectIndex <= array->count) && (newObject != NULL))) { [newObject autorelease]; return; }
1350- array->count++;
1351- if(array->count >= array->capacity) {
1352- array->capacity += 16UL;
1353- id *newObjects = NULL;
1354- if((newObjects = (id *)realloc(array->objects, sizeof(id) * array->capacity)) == NULL) { [NSException raise:NSMallocException format:@"Unable to resize objects array."]; }
1355- array->objects = newObjects;
1356- memset(&array->objects[array->count], 0, sizeof(id) * (array->capacity - array->count));
1357- }
1358- if((objectIndex + 1UL) < array->count) { memmove(&array->objects[objectIndex + 1UL], &array->objects[objectIndex], sizeof(id) * ((array->count - 1UL) - objectIndex)); array->objects[objectIndex] = NULL; }
1359- array->objects[objectIndex] = newObject;
1360-}
1361-
1362-// Note: The caller is responsible for -retaining the object that is to be added.
1363-static void _JKArrayReplaceObjectAtIndexWithObject(JKArray *array, NSUInteger objectIndex, id newObject) {
1364- NSCParameterAssert((array != NULL) && (array->objects != NULL) && (array->count <= array->capacity) && (objectIndex < array->count) && (array->objects[objectIndex] != NULL) && (newObject != NULL));
1365- if(!((array != NULL) && (array->objects != NULL) && (objectIndex < array->count) && (array->objects[objectIndex] != NULL) && (newObject != NULL))) { [newObject autorelease]; return; }
1366- CFRelease(array->objects[objectIndex]);
1367- array->objects[objectIndex] = NULL;
1368- array->objects[objectIndex] = newObject;
1369-}
1370-
1371-static void _JKArrayRemoveObjectAtIndex(JKArray *array, NSUInteger objectIndex) {
1372- NSCParameterAssert((array != NULL) && (array->objects != NULL) && (array->count <= array->capacity) && (objectIndex < array->count) && (array->objects[objectIndex] != NULL));
1373- if(!((array != NULL) && (array->objects != NULL) && (objectIndex < array->count) && (array->objects[objectIndex] != NULL))) { return; }
1374- CFRelease(array->objects[objectIndex]);
1375- array->objects[objectIndex] = NULL;
1376- if((objectIndex + 1UL) < array->count) { memmove(&array->objects[objectIndex], &array->objects[objectIndex + 1UL], sizeof(id) * ((array->count - 1UL) - objectIndex)); array->objects[array->count] = NULL; }
1377- array->count--;
1378-}
1379-
1380-- (void)dealloc
1381-{
1382- if(JK_EXPECT_T(objects != NULL)) {
1383- NSUInteger atObject = 0UL;
1384- for(atObject = 0UL; atObject < count; atObject++) { if(JK_EXPECT_T(objects[atObject] != NULL)) { CFRelease(objects[atObject]); objects[atObject] = NULL; } }
1385- free(objects); objects = NULL;
1386- }
1387-
1388- [super dealloc];
1389-}
1390-
1391-- (NSUInteger)count
1392-{
1393- NSParameterAssert((objects != NULL) && (count <= capacity));
1394- return(count);
1395-}
1396-
1397-- (void)getObjects:(id *)objectsPtr range:(NSRange)range
1398-{
1399- NSParameterAssert((objects != NULL) && (count <= capacity));
1400- if((objectsPtr == NULL) && (NSMaxRange(range) > 0UL)) { [NSException raise:NSRangeException format:@"*** -[%@ %@]: pointer to objects array is NULL but range length is %lu", NSStringFromClass([self class]), NSStringFromSelector(_cmd), NSMaxRange(range)]; }
1401- if((range.location > count) || (NSMaxRange(range) > count)) { [NSException raise:NSRangeException format:@"*** -[%@ %@]: index (%lu) beyond bounds (%lu)", NSStringFromClass([self class]), NSStringFromSelector(_cmd), NSMaxRange(range), count]; }
1402- memcpy(objectsPtr, objects + range.location, range.length * sizeof(id));
1403-}
1404-
1405-- (id)objectAtIndex:(NSUInteger)objectIndex
1406-{
1407- if(objectIndex >= count) { [NSException raise:NSRangeException format:@"*** -[%@ %@]: index (%lu) beyond bounds (%lu)", NSStringFromClass([self class]), NSStringFromSelector(_cmd), objectIndex, count]; }
1408- NSParameterAssert((objects != NULL) && (count <= capacity) && (objects[objectIndex] != NULL));
1409- return(objects[objectIndex]);
1410-}
1411-
1412-- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len
1413-{
1414- NSParameterAssert((state != NULL) && (stackbuf != NULL) && (len > 0UL) && (objects != NULL) && (count <= capacity));
1415- if(JK_EXPECT_F(state->state == 0UL)) { state->mutationsPtr = (unsigned long *)&mutations; state->itemsPtr = stackbuf; }
1416- if(JK_EXPECT_F(state->state >= count)) { return(0UL); }
1417-
1418- NSUInteger enumeratedCount = 0UL;
1419- while(JK_EXPECT_T(enumeratedCount < len) && JK_EXPECT_T(state->state < count)) { NSParameterAssert(objects[state->state] != NULL); stackbuf[enumeratedCount++] = objects[state->state++]; }
1420-
1421- return(enumeratedCount);
1422-}
1423-
1424-- (void)insertObject:(id)anObject atIndex:(NSUInteger)objectIndex
1425-{
1426- if(mutations == 0UL) { [NSException raise:NSInternalInconsistencyException format:@"*** -[%@ %@]: mutating method sent to immutable object", NSStringFromClass([self class]), NSStringFromSelector(_cmd)]; }
1427- if(anObject == NULL) { [NSException raise:NSInvalidArgumentException format:@"*** -[%@ %@]: attempt to insert nil", NSStringFromClass([self class]), NSStringFromSelector(_cmd)]; }
1428- if(objectIndex > count) { [NSException raise:NSRangeException format:@"*** -[%@ %@]: index (%lu) beyond bounds (%lu)", NSStringFromClass([self class]), NSStringFromSelector(_cmd), objectIndex, count + 1UL]; }
1429-#ifdef __clang_analyzer__
1430- [anObject retain]; // Stupid clang analyzer... Issue #19.
1431-#else
1432- anObject = [anObject retain];
1433-#endif
1434- _JKArrayInsertObjectAtIndex(self, anObject, objectIndex);
1435- mutations = (mutations == NSUIntegerMax) ? 1UL : mutations + 1UL;
1436-}
1437-
1438-- (void)removeObjectAtIndex:(NSUInteger)objectIndex
1439-{
1440- if(mutations == 0UL) { [NSException raise:NSInternalInconsistencyException format:@"*** -[%@ %@]: mutating method sent to immutable object", NSStringFromClass([self class]), NSStringFromSelector(_cmd)]; }
1441- if(objectIndex >= count) { [NSException raise:NSRangeException format:@"*** -[%@ %@]: index (%lu) beyond bounds (%lu)", NSStringFromClass([self class]), NSStringFromSelector(_cmd), objectIndex, count]; }
1442- _JKArrayRemoveObjectAtIndex(self, objectIndex);
1443- mutations = (mutations == NSUIntegerMax) ? 1UL : mutations + 1UL;
1444-}
1445-
1446-- (void)replaceObjectAtIndex:(NSUInteger)objectIndex withObject:(id)anObject
1447-{
1448- if(mutations == 0UL) { [NSException raise:NSInternalInconsistencyException format:@"*** -[%@ %@]: mutating method sent to immutable object", NSStringFromClass([self class]), NSStringFromSelector(_cmd)]; }
1449- if(anObject == NULL) { [NSException raise:NSInvalidArgumentException format:@"*** -[%@ %@]: attempt to insert nil", NSStringFromClass([self class]), NSStringFromSelector(_cmd)]; }
1450- if(objectIndex >= count) { [NSException raise:NSRangeException format:@"*** -[%@ %@]: index (%lu) beyond bounds (%lu)", NSStringFromClass([self class]), NSStringFromSelector(_cmd), objectIndex, count]; }
1451-#ifdef __clang_analyzer__
1452- [anObject retain]; // Stupid clang analyzer... Issue #19.
1453-#else
1454- anObject = [anObject retain];
1455-#endif
1456- _JKArrayReplaceObjectAtIndexWithObject(self, objectIndex, anObject);
1457- mutations = (mutations == NSUIntegerMax) ? 1UL : mutations + 1UL;
1458-}
1459-
1460-- (id)copyWithZone:(NSZone *)zone
1461-{
1462- NSParameterAssert((objects != NULL) && (count <= capacity));
1463- return((mutations == 0UL) ? [self retain] : [[NSArray allocWithZone:zone] initWithObjects:objects count:count]);
1464-}
1465-
1466-- (id)mutableCopyWithZone:(NSZone *)zone
1467-{
1468- NSParameterAssert((objects != NULL) && (count <= capacity));
1469- return([[NSMutableArray allocWithZone:zone] initWithObjects:objects count:count]);
1470-}
1471-
1472-@end
1473-
1474-
1475-#pragma mark -
1476-@interface JKDictionaryEnumerator : NSEnumerator {
1477- id collection;
1478- NSUInteger nextObject;
1479-}
1480-
1481-- (id)initWithJKDictionary:(JKDictionary *)initDictionary;
1482-- (NSArray *)allObjects;
1483-- (id)nextObject;
1484-
1485-@end
1486-
1487-@implementation JKDictionaryEnumerator
1488-
1489-- (id)initWithJKDictionary:(JKDictionary *)initDictionary
1490-{
1491- NSParameterAssert(initDictionary != NULL);
1492- if((self = [super init]) == NULL) { return(NULL); }
1493- if((collection = (id)CFRetain(initDictionary)) == NULL) { [self autorelease]; return(NULL); }
1494- return(self);
1495-}
1496-
1497-- (void)dealloc
1498-{
1499- if(collection != NULL) { CFRelease(collection); collection = NULL; }
1500- [super dealloc];
1501-}
1502-
1503-- (NSArray *)allObjects
1504-{
1505- NSParameterAssert(collection != NULL);
1506- NSUInteger count = [collection count], atObject = 0UL;
1507- id objects[count];
1508-
1509- while((objects[atObject] = [self nextObject]) != NULL) { NSParameterAssert(atObject < count); atObject++; }
1510-
1511- return([NSArray arrayWithObjects:objects count:atObject]);
1512-}
1513-
1514-- (id)nextObject
1515-{
1516- NSParameterAssert((collection != NULL) && (_JKDictionaryHashEntry(collection) != NULL));
1517- JKHashTableEntry *entry = _JKDictionaryHashEntry(collection);
1518- NSUInteger capacity = _JKDictionaryCapacity(collection);
1519- id returnObject = NULL;
1520-
1521- if(entry != NULL) { while((nextObject < capacity) && ((returnObject = entry[nextObject++].key) == NULL)) { /* ... */ } }
1522-
1523- return(returnObject);
1524-}
1525-
1526-@end
1527-
1528-#pragma mark -
1529-@interface JKDictionary : NSMutableDictionary <NSCopying, NSMutableCopying, NSFastEnumeration> {
1530- NSUInteger count, capacity, mutations;
1531- JKHashTableEntry *entry;
1532-}
1533-@end
1534-
1535-@implementation JKDictionary
1536-
1537-+ (id)allocWithZone:(NSZone *)zone
1538-{
1539-#pragma unused(zone)
1540- [NSException raise:NSInvalidArgumentException format:@"*** - [%@ %@]: The %@ class is private to JSONKit and should not be used in this fashion.", NSStringFromClass([self class]), NSStringFromSelector(_cmd), NSStringFromClass([self class])];
1541- return(NULL);
1542-}
1543-
1544-// These values are taken from Core Foundation CF-550 CFBasicHash.m. As a bonus, they align very well with our JKHashTableEntry struct too.
1545-static const NSUInteger jk_dictionaryCapacities[] = {
1546- 0UL, 3UL, 7UL, 13UL, 23UL, 41UL, 71UL, 127UL, 191UL, 251UL, 383UL, 631UL, 1087UL, 1723UL,
1547- 2803UL, 4523UL, 7351UL, 11959UL, 19447UL, 31231UL, 50683UL, 81919UL, 132607UL,
1548- 214519UL, 346607UL, 561109UL, 907759UL, 1468927UL, 2376191UL, 3845119UL,
1549- 6221311UL, 10066421UL, 16287743UL, 26354171UL, 42641881UL, 68996069UL,
1550- 111638519UL, 180634607UL, 292272623UL, 472907251UL
1551-};
1552-
1553-static NSUInteger _JKDictionaryCapacityForCount(NSUInteger count) {
1554- NSUInteger bottom = 0UL, top = sizeof(jk_dictionaryCapacities) / sizeof(NSUInteger), mid = 0UL, tableSize = lround(floor((count) * 1.33));
1555- while(top > bottom) { mid = (top + bottom) / 2UL; if(jk_dictionaryCapacities[mid] < tableSize) { bottom = mid + 1UL; } else { top = mid; } }
1556- return(jk_dictionaryCapacities[bottom]);
1557-}
1558-
1559-static void _JKDictionaryResizeIfNeccessary(JKDictionary *dictionary) {
1560- NSCParameterAssert((dictionary != NULL) && (dictionary->entry != NULL) && (dictionary->count <= dictionary->capacity));
1561-
1562- NSUInteger capacityForCount = 0UL;
1563- if(dictionary->capacity < (capacityForCount = _JKDictionaryCapacityForCount(dictionary->count + 1UL))) { // resize
1564- NSUInteger oldCapacity = dictionary->capacity;
1565-#ifndef NS_BLOCK_ASSERTIONS
1566- NSUInteger oldCount = dictionary->count;
1567-#endif
1568- JKHashTableEntry *oldEntry = dictionary->entry;
1569- if(JK_EXPECT_F((dictionary->entry = (JKHashTableEntry *)calloc(1UL, sizeof(JKHashTableEntry) * capacityForCount)) == NULL)) { [NSException raise:NSMallocException format:@"Unable to allocate memory for hash table."]; }
1570- dictionary->capacity = capacityForCount;
1571- dictionary->count = 0UL;
1572-
1573- NSUInteger idx = 0UL;
1574- for(idx = 0UL; idx < oldCapacity; idx++) { if(oldEntry[idx].key != NULL) { _JKDictionaryAddObject(dictionary, oldEntry[idx].keyHash, oldEntry[idx].key, oldEntry[idx].object); oldEntry[idx].keyHash = 0UL; oldEntry[idx].key = NULL; oldEntry[idx].object = NULL; } }
1575- NSCParameterAssert((oldCount == dictionary->count));
1576- free(oldEntry); oldEntry = NULL;
1577- }
1578-}
1579-
1580-static JKDictionary *_JKDictionaryCreate(id *keys, NSUInteger *keyHashes, id *objects, NSUInteger count, BOOL mutableCollection) {
1581- NSCParameterAssert((keys != NULL) && (keyHashes != NULL) && (objects != NULL) && (_JKDictionaryClass != NULL) && (_JKDictionaryInstanceSize > 0UL));
1582- JKDictionary *dictionary = NULL;
1583- if(JK_EXPECT_T((dictionary = (JKDictionary *)calloc(1UL, _JKDictionaryInstanceSize)) != NULL)) { // Directly allocate the JKDictionary instance via calloc.
1584- dictionary->isa = _JKDictionaryClass;
1585- if((dictionary = [dictionary init]) == NULL) { return(NULL); }
1586- dictionary->capacity = _JKDictionaryCapacityForCount(count);
1587- dictionary->count = 0UL;
1588-
1589- if(JK_EXPECT_F((dictionary->entry = (JKHashTableEntry *)calloc(1UL, sizeof(JKHashTableEntry) * dictionary->capacity)) == NULL)) { [dictionary autorelease]; return(NULL); }
1590-
1591- NSUInteger idx = 0UL;
1592- for(idx = 0UL; idx < count; idx++) { _JKDictionaryAddObject(dictionary, keyHashes[idx], keys[idx], objects[idx]); }
1593-
1594- dictionary->mutations = (mutableCollection == NO) ? 0UL : 1UL;
1595- }
1596- return(dictionary);
1597-}
1598-
1599-- (void)dealloc
1600-{
1601- if(JK_EXPECT_T(entry != NULL)) {
1602- NSUInteger atEntry = 0UL;
1603- for(atEntry = 0UL; atEntry < capacity; atEntry++) {
1604- if(JK_EXPECT_T(entry[atEntry].key != NULL)) { CFRelease(entry[atEntry].key); entry[atEntry].key = NULL; }
1605- if(JK_EXPECT_T(entry[atEntry].object != NULL)) { CFRelease(entry[atEntry].object); entry[atEntry].object = NULL; }
1606- }
1607-
1608- free(entry); entry = NULL;
1609- }
1610-
1611- [super dealloc];
1612-}
1613-
1614-static JKHashTableEntry *_JKDictionaryHashEntry(JKDictionary *dictionary) {
1615- NSCParameterAssert(dictionary != NULL);
1616- return(dictionary->entry);
1617-}
1618-
1619-static NSUInteger _JKDictionaryCapacity(JKDictionary *dictionary) {
1620- NSCParameterAssert(dictionary != NULL);
1621- return(dictionary->capacity);
1622-}
1623-
1624-static void _JKDictionaryRemoveObjectWithEntry(JKDictionary *dictionary, JKHashTableEntry *entry) {
1625- NSCParameterAssert((dictionary != NULL) && (entry != NULL) && (entry->key != NULL) && (entry->object != NULL) && (dictionary->count > 0UL) && (dictionary->count <= dictionary->capacity));
1626- CFRelease(entry->key); entry->key = NULL;
1627- CFRelease(entry->object); entry->object = NULL;
1628- entry->keyHash = 0UL;
1629- dictionary->count--;
1630- // In order for certain invariants that are used to speed up the search for a particular key, we need to "re-add" all the entries in the hash table following this entry until we hit a NULL entry.
1631- NSUInteger removeIdx = entry - dictionary->entry, idx = 0UL;
1632- NSCParameterAssert((removeIdx < dictionary->capacity));
1633- for(idx = 0UL; idx < dictionary->capacity; idx++) {
1634- NSUInteger entryIdx = (removeIdx + idx + 1UL) % dictionary->capacity;
1635- JKHashTableEntry *atEntry = &dictionary->entry[entryIdx];
1636- if(atEntry->key == NULL) { break; }
1637- NSUInteger keyHash = atEntry->keyHash;
1638- id key = atEntry->key, object = atEntry->object;
1639- NSCParameterAssert(object != NULL);
1640- atEntry->keyHash = 0UL;
1641- atEntry->key = NULL;
1642- atEntry->object = NULL;
1643- NSUInteger addKeyEntry = keyHash % dictionary->capacity, addIdx = 0UL;
1644- for(addIdx = 0UL; addIdx < dictionary->capacity; addIdx++) {
1645- JKHashTableEntry *atAddEntry = &dictionary->entry[((addKeyEntry + addIdx) % dictionary->capacity)];
1646- if(JK_EXPECT_T(atAddEntry->key == NULL)) { NSCParameterAssert((atAddEntry->keyHash == 0UL) && (atAddEntry->object == NULL)); atAddEntry->key = key; atAddEntry->object = object; atAddEntry->keyHash = keyHash; break; }
1647- }
1648- }
1649-}
1650-
1651-static void _JKDictionaryAddObject(JKDictionary *dictionary, NSUInteger keyHash, id key, id object) {
1652- NSCParameterAssert((dictionary != NULL) && (key != NULL) && (object != NULL) && (dictionary->count < dictionary->capacity) && (dictionary->entry != NULL));
1653- NSUInteger keyEntry = keyHash % dictionary->capacity, idx = 0UL;
1654- for(idx = 0UL; idx < dictionary->capacity; idx++) {
1655- NSUInteger entryIdx = (keyEntry + idx) % dictionary->capacity;
1656- JKHashTableEntry *atEntry = &dictionary->entry[entryIdx];
1657- if(JK_EXPECT_F(atEntry->keyHash == keyHash) && JK_EXPECT_T(atEntry->key != NULL) && (JK_EXPECT_F(key == atEntry->key) || JK_EXPECT_F(CFEqual(atEntry->key, key)))) { _JKDictionaryRemoveObjectWithEntry(dictionary, atEntry); }
1658- if(JK_EXPECT_T(atEntry->key == NULL)) { NSCParameterAssert((atEntry->keyHash == 0UL) && (atEntry->object == NULL)); atEntry->key = key; atEntry->object = object; atEntry->keyHash = keyHash; dictionary->count++; return; }
1659- }
1660-
1661- // We should never get here. If we do, we -release the key / object because it's our responsibility.
1662- CFRelease(key);
1663- CFRelease(object);
1664-}
1665-
1666-- (NSUInteger)count
1667-{
1668- return(count);
1669-}
1670-
1671-static JKHashTableEntry *_JKDictionaryHashTableEntryForKey(JKDictionary *dictionary, id aKey) {
1672- NSCParameterAssert((dictionary != NULL) && (dictionary->entry != NULL) && (dictionary->count <= dictionary->capacity));
1673- if((aKey == NULL) || (dictionary->capacity == 0UL)) { return(NULL); }
1674- NSUInteger keyHash = CFHash(aKey), keyEntry = (keyHash % dictionary->capacity), idx = 0UL;
1675- JKHashTableEntry *atEntry = NULL;
1676- for(idx = 0UL; idx < dictionary->capacity; idx++) {
1677- atEntry = &dictionary->entry[(keyEntry + idx) % dictionary->capacity];
1678- if(JK_EXPECT_T(atEntry->keyHash == keyHash) && JK_EXPECT_T(atEntry->key != NULL) && ((atEntry->key == aKey) || CFEqual(atEntry->key, aKey))) { NSCParameterAssert(atEntry->object != NULL); return(atEntry); break; }
1679- if(JK_EXPECT_F(atEntry->key == NULL)) { NSCParameterAssert(atEntry->object == NULL); return(NULL); break; } // If the key was in the table, we would have found it by now.
1680- }
1681- return(NULL);
1682-}
1683-
1684-- (id)objectForKey:(id)aKey
1685-{
1686- NSParameterAssert((entry != NULL) && (count <= capacity));
1687- JKHashTableEntry *entryForKey = _JKDictionaryHashTableEntryForKey(self, aKey);
1688- return((entryForKey != NULL) ? entryForKey->object : NULL);
1689-}
1690-
1691-- (void)getObjects:(id *)objects andKeys:(id *)keys
1692-{
1693- NSParameterAssert((entry != NULL) && (count <= capacity));
1694- NSUInteger atEntry = 0UL; NSUInteger arrayIdx = 0UL;
1695- for(atEntry = 0UL; atEntry < capacity; atEntry++) {
1696- if(JK_EXPECT_T(entry[atEntry].key != NULL)) {
1697- NSCParameterAssert((entry[atEntry].object != NULL) && (arrayIdx < count));
1698- if(JK_EXPECT_T(keys != NULL)) { keys[arrayIdx] = entry[atEntry].key; }
1699- if(JK_EXPECT_T(objects != NULL)) { objects[arrayIdx] = entry[atEntry].object; }
1700- arrayIdx++;
1701- }
1702- }
1703-}
1704-
1705-- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len
1706-{
1707- NSParameterAssert((state != NULL) && (stackbuf != NULL) && (len > 0UL) && (entry != NULL) && (count <= capacity));
1708- if(JK_EXPECT_F(state->state == 0UL)) { state->mutationsPtr = (unsigned long *)&mutations; state->itemsPtr = stackbuf; }
1709- if(JK_EXPECT_F(state->state >= capacity)) { return(0UL); }
1710-
1711- NSUInteger enumeratedCount = 0UL;
1712- while(JK_EXPECT_T(enumeratedCount < len) && JK_EXPECT_T(state->state < capacity)) { if(JK_EXPECT_T(entry[state->state].key != NULL)) { stackbuf[enumeratedCount++] = entry[state->state].key; } state->state++; }
1713-
1714- return(enumeratedCount);
1715-}
1716-
1717-- (NSEnumerator *)keyEnumerator
1718-{
1719- return([[[JKDictionaryEnumerator alloc] initWithJKDictionary:self] autorelease]);
1720-}
1721-
1722-- (void)setObject:(id)anObject forKey:(id)aKey
1723-{
1724- if(mutations == 0UL) { [NSException raise:NSInternalInconsistencyException format:@"*** -[%@ %@]: mutating method sent to immutable object", NSStringFromClass([self class]), NSStringFromSelector(_cmd)]; }
1725- if(aKey == NULL) { [NSException raise:NSInvalidArgumentException format:@"*** -[%@ %@]: attempt to insert nil key", NSStringFromClass([self class]), NSStringFromSelector(_cmd)]; }
1726- if(anObject == NULL) { [NSException raise:NSInvalidArgumentException format:@"*** -[%@ %@]: attempt to insert nil value (key: %@)", NSStringFromClass([self class]), NSStringFromSelector(_cmd), aKey]; }
1727-
1728- _JKDictionaryResizeIfNeccessary(self);
1729-#ifndef __clang_analyzer__
1730- aKey = [aKey copy]; // Why on earth would clang complain that this -copy "might leak",
1731- anObject = [anObject retain]; // but this -retain doesn't!?
1732-#endif // __clang_analyzer__
1733- _JKDictionaryAddObject(self, CFHash(aKey), aKey, anObject);
1734- mutations = (mutations == NSUIntegerMax) ? 1UL : mutations + 1UL;
1735-}
1736-
1737-- (void)removeObjectForKey:(id)aKey
1738-{
1739- if(mutations == 0UL) { [NSException raise:NSInternalInconsistencyException format:@"*** -[%@ %@]: mutating method sent to immutable object", NSStringFromClass([self class]), NSStringFromSelector(_cmd)]; }
1740- if(aKey == NULL) { [NSException raise:NSInvalidArgumentException format:@"*** -[%@ %@]: attempt to remove nil key", NSStringFromClass([self class]), NSStringFromSelector(_cmd)]; }
1741- JKHashTableEntry *entryForKey = _JKDictionaryHashTableEntryForKey(self, aKey);
1742- if(entryForKey != NULL) {
1743- _JKDictionaryRemoveObjectWithEntry(self, entryForKey);
1744- mutations = (mutations == NSUIntegerMax) ? 1UL : mutations + 1UL;
1745- }
1746-}
1747-
1748-- (id)copyWithZone:(NSZone *)zone
1749-{
1750- NSParameterAssert((entry != NULL) && (count <= capacity));
1751- return((mutations == 0UL) ? [self retain] : [[NSDictionary allocWithZone:zone] initWithDictionary:self]);
1752-}
1753-
1754-- (id)mutableCopyWithZone:(NSZone *)zone
1755-{
1756- NSParameterAssert((entry != NULL) && (count <= capacity));
1757- return([[NSMutableDictionary allocWithZone:zone] initWithDictionary:self]);
1758-}
1759-
1760-@end
1761-
1762-
1763-
1764-#pragma mark -
1765-
1766-JK_STATIC_INLINE size_t jk_min(size_t a, size_t b) { return((a < b) ? a : b); }
1767-JK_STATIC_INLINE size_t jk_max(size_t a, size_t b) { return((a > b) ? a : b); }
1768-
1769-JK_STATIC_INLINE JKHash calculateHash(JKHash currentHash, unsigned char c) { return(((currentHash << 5) + currentHash) + c); }
1770-
1771-static void jk_error(JKParseState *parseState, NSString *format, ...) {
1772- NSCParameterAssert((parseState != NULL) && (format != NULL));
1773-
1774- va_list varArgsList;
1775- va_start(varArgsList, format);
1776- NSString *formatString = [[[NSString alloc] initWithFormat:format arguments:varArgsList] autorelease];
1777- va_end(varArgsList);
1778-
1779-#if 0
1780- const unsigned char *lineStart = parseState->stringBuffer.bytes.ptr + parseState->lineStartIndex;
1781- const unsigned char *lineEnd = lineStart;
1782- const unsigned char *atCharacterPtr = NULL;
1783-
1784- for(atCharacterPtr = lineStart; atCharacterPtr < JK_END_STRING_PTR(parseState); atCharacterPtr++) { lineEnd = atCharacterPtr; if(jk_parse_is_newline(parseState, atCharacterPtr)) { break; } }
1785-
1786- NSString *lineString = @"", *carretString = @"";
1787- if(lineStart < JK_END_STRING_PTR(parseState)) {
1788- lineString = [[[NSString alloc] initWithBytes:lineStart length:(lineEnd - lineStart) encoding:NSUTF8StringEncoding] autorelease];
1789- carretString = [NSString stringWithFormat:@"%*.*s^", (int)(parseState->atIndex - parseState->lineStartIndex), (int)(parseState->atIndex - parseState->lineStartIndex), " "];
1790- }
1791-#endif
1792-
1793- if(parseState->error == NULL) {
1794- parseState->error = [NSError errorWithDomain:@"JKErrorDomain" code:-1L userInfo:
1795- [NSDictionary dictionaryWithObjectsAndKeys:
1796- formatString, NSLocalizedDescriptionKey,
1797- [NSNumber numberWithUnsignedLong:parseState->atIndex], @"JKAtIndexKey",
1798- [NSNumber numberWithUnsignedLong:parseState->lineNumber], @"JKLineNumberKey",
1799- //lineString, @"JKErrorLine0Key",
1800- //carretString, @"JKErrorLine1Key",
1801- NULL]];
1802- }
1803-}
1804-
1805-#pragma mark -
1806-#pragma mark Buffer and Object Stack management functions
1807-
1808-static void jk_managedBuffer_release(JKManagedBuffer *managedBuffer) {
1809- if((managedBuffer->flags & JKManagedBufferMustFree)) {
1810- if(managedBuffer->bytes.ptr != NULL) { free(managedBuffer->bytes.ptr); managedBuffer->bytes.ptr = NULL; }
1811- managedBuffer->flags &= ~JKManagedBufferMustFree;
1812- }
1813-
1814- managedBuffer->bytes.ptr = NULL;
1815- managedBuffer->bytes.length = 0UL;
1816- managedBuffer->flags &= ~JKManagedBufferLocationMask;
1817-}
1818-
1819-static void jk_managedBuffer_setToStackBuffer(JKManagedBuffer *managedBuffer, unsigned char *ptr, size_t length) {
1820- jk_managedBuffer_release(managedBuffer);
1821- managedBuffer->bytes.ptr = ptr;
1822- managedBuffer->bytes.length = length;
1823- managedBuffer->flags = (managedBuffer->flags & ~JKManagedBufferLocationMask) | JKManagedBufferOnStack;
1824-}
1825-
1826-static unsigned char *jk_managedBuffer_resize(JKManagedBuffer *managedBuffer, size_t newSize) {
1827- size_t roundedUpNewSize = newSize;
1828-
1829- if(managedBuffer->roundSizeUpToMultipleOf > 0UL) { roundedUpNewSize = newSize + ((managedBuffer->roundSizeUpToMultipleOf - (newSize % managedBuffer->roundSizeUpToMultipleOf)) % managedBuffer->roundSizeUpToMultipleOf); }
1830-
1831- if((roundedUpNewSize != managedBuffer->bytes.length) && (roundedUpNewSize > managedBuffer->bytes.length)) {
1832- if((managedBuffer->flags & JKManagedBufferLocationMask) == JKManagedBufferOnStack) {
1833- NSCParameterAssert((managedBuffer->flags & JKManagedBufferMustFree) == 0);
1834- unsigned char *newBuffer = NULL, *oldBuffer = managedBuffer->bytes.ptr;
1835-
1836- if((newBuffer = (unsigned char *)malloc(roundedUpNewSize)) == NULL) { return(NULL); }
1837- memcpy(newBuffer, oldBuffer, jk_min(managedBuffer->bytes.length, roundedUpNewSize));
1838- managedBuffer->flags = (managedBuffer->flags & ~JKManagedBufferLocationMask) | (JKManagedBufferOnHeap | JKManagedBufferMustFree);
1839- managedBuffer->bytes.ptr = newBuffer;
1840- managedBuffer->bytes.length = roundedUpNewSize;
1841- } else {
1842- NSCParameterAssert(((managedBuffer->flags & JKManagedBufferMustFree) != 0) && ((managedBuffer->flags & JKManagedBufferLocationMask) == JKManagedBufferOnHeap));
1843- if((managedBuffer->bytes.ptr = (unsigned char *)reallocf(managedBuffer->bytes.ptr, roundedUpNewSize)) == NULL) { return(NULL); }
1844- managedBuffer->bytes.length = roundedUpNewSize;
1845- }
1846- }
1847-
1848- return(managedBuffer->bytes.ptr);
1849-}
1850-
1851-
1852-
1853-static void jk_objectStack_release(JKObjectStack *objectStack) {
1854- NSCParameterAssert(objectStack != NULL);
1855-
1856- NSCParameterAssert(objectStack->index <= objectStack->count);
1857- size_t atIndex = 0UL;
1858- for(atIndex = 0UL; atIndex < objectStack->index; atIndex++) {
1859- if(objectStack->objects[atIndex] != NULL) { CFRelease(objectStack->objects[atIndex]); objectStack->objects[atIndex] = NULL; }
1860- if(objectStack->keys[atIndex] != NULL) { CFRelease(objectStack->keys[atIndex]); objectStack->keys[atIndex] = NULL; }
1861- }
1862- objectStack->index = 0UL;
1863-
1864- if(objectStack->flags & JKObjectStackMustFree) {
1865- NSCParameterAssert((objectStack->flags & JKObjectStackLocationMask) == JKObjectStackOnHeap);
1866- if(objectStack->objects != NULL) { free(objectStack->objects); objectStack->objects = NULL; }
1867- if(objectStack->keys != NULL) { free(objectStack->keys); objectStack->keys = NULL; }
1868- if(objectStack->cfHashes != NULL) { free(objectStack->cfHashes); objectStack->cfHashes = NULL; }
1869- objectStack->flags &= ~JKObjectStackMustFree;
1870- }
1871-
1872- objectStack->objects = NULL;
1873- objectStack->keys = NULL;
1874- objectStack->cfHashes = NULL;
1875-
1876- objectStack->count = 0UL;
1877- objectStack->flags &= ~JKObjectStackLocationMask;
1878-}
1879-
1880-static void jk_objectStack_setToStackBuffer(JKObjectStack *objectStack, void **objects, void **keys, CFHashCode *cfHashes, size_t count) {
1881- NSCParameterAssert((objectStack != NULL) && (objects != NULL) && (keys != NULL) && (cfHashes != NULL) && (count > 0UL));
1882- jk_objectStack_release(objectStack);
1883- objectStack->objects = objects;
1884- objectStack->keys = keys;
1885- objectStack->cfHashes = cfHashes;
1886- objectStack->count = count;
1887- objectStack->flags = (objectStack->flags & ~JKObjectStackLocationMask) | JKObjectStackOnStack;
1888-#ifndef NS_BLOCK_ASSERTIONS
1889- size_t idx;
1890- for(idx = 0UL; idx < objectStack->count; idx++) { objectStack->objects[idx] = NULL; objectStack->keys[idx] = NULL; objectStack->cfHashes[idx] = 0UL; }
1891-#endif
1892-}
1893-
1894-static int jk_objectStack_resize(JKObjectStack *objectStack, size_t newCount) {
1895- size_t roundedUpNewCount = newCount;
1896- int returnCode = 0;
1897-
1898- void **newObjects = NULL, **newKeys = NULL;
1899- CFHashCode *newCFHashes = NULL;
1900-
1901- if(objectStack->roundSizeUpToMultipleOf > 0UL) { roundedUpNewCount = newCount + ((objectStack->roundSizeUpToMultipleOf - (newCount % objectStack->roundSizeUpToMultipleOf)) % objectStack->roundSizeUpToMultipleOf); }
1902-
1903- if((roundedUpNewCount != objectStack->count) && (roundedUpNewCount > objectStack->count)) {
1904- if((objectStack->flags & JKObjectStackLocationMask) == JKObjectStackOnStack) {
1905- NSCParameterAssert((objectStack->flags & JKObjectStackMustFree) == 0);
1906-
1907- if((newObjects = (void ** )calloc(1UL, roundedUpNewCount * sizeof(void * ))) == NULL) { returnCode = 1; goto errorExit; }
1908- memcpy(newObjects, objectStack->objects, jk_min(objectStack->count, roundedUpNewCount) * sizeof(void *));
1909- if((newKeys = (void ** )calloc(1UL, roundedUpNewCount * sizeof(void * ))) == NULL) { returnCode = 1; goto errorExit; }
1910- memcpy(newKeys, objectStack->keys, jk_min(objectStack->count, roundedUpNewCount) * sizeof(void *));
1911-
1912- if((newCFHashes = (CFHashCode *)calloc(1UL, roundedUpNewCount * sizeof(CFHashCode))) == NULL) { returnCode = 1; goto errorExit; }
1913- memcpy(newCFHashes, objectStack->cfHashes, jk_min(objectStack->count, roundedUpNewCount) * sizeof(CFHashCode));
1914-
1915- objectStack->flags = (objectStack->flags & ~JKObjectStackLocationMask) | (JKObjectStackOnHeap | JKObjectStackMustFree);
1916- objectStack->objects = newObjects; newObjects = NULL;
1917- objectStack->keys = newKeys; newKeys = NULL;
1918- objectStack->cfHashes = newCFHashes; newCFHashes = NULL;
1919- objectStack->count = roundedUpNewCount;
1920- } else {
1921- NSCParameterAssert(((objectStack->flags & JKObjectStackMustFree) != 0) && ((objectStack->flags & JKObjectStackLocationMask) == JKObjectStackOnHeap));
1922- if((newObjects = (void ** )realloc(objectStack->objects, roundedUpNewCount * sizeof(void * ))) != NULL) { objectStack->objects = newObjects; newObjects = NULL; } else { returnCode = 1; goto errorExit; }
1923- if((newKeys = (void ** )realloc(objectStack->keys, roundedUpNewCount * sizeof(void * ))) != NULL) { objectStack->keys = newKeys; newKeys = NULL; } else { returnCode = 1; goto errorExit; }
1924- if((newCFHashes = (CFHashCode *)realloc(objectStack->cfHashes, roundedUpNewCount * sizeof(CFHashCode))) != NULL) { objectStack->cfHashes = newCFHashes; newCFHashes = NULL; } else { returnCode = 1; goto errorExit; }
1925-
1926-#ifndef NS_BLOCK_ASSERTIONS
1927- size_t idx;
1928- for(idx = objectStack->count; idx < roundedUpNewCount; idx++) { objectStack->objects[idx] = NULL; objectStack->keys[idx] = NULL; objectStack->cfHashes[idx] = 0UL; }
1929-#endif
1930- objectStack->count = roundedUpNewCount;
1931- }
1932- }
1933-
1934- errorExit:
1935- if(newObjects != NULL) { free(newObjects); newObjects = NULL; }
1936- if(newKeys != NULL) { free(newKeys); newKeys = NULL; }
1937- if(newCFHashes != NULL) { free(newCFHashes); newCFHashes = NULL; }
1938-
1939- return(returnCode);
1940-}
1941-
1942-////////////
1943-#pragma mark -
1944-#pragma mark Unicode related functions
1945-
1946-JK_STATIC_INLINE ConversionResult isValidCodePoint(UTF32 *u32CodePoint) {
1947- ConversionResult result = conversionOK;
1948- UTF32 ch = *u32CodePoint;
1949-
1950- if(JK_EXPECT_F(ch >= UNI_SUR_HIGH_START) && (JK_EXPECT_T(ch <= UNI_SUR_LOW_END))) { result = sourceIllegal; ch = UNI_REPLACEMENT_CHAR; goto finished; }
1951- if(JK_EXPECT_F(ch >= 0xFDD0U) && (JK_EXPECT_F(ch <= 0xFDEFU) || JK_EXPECT_F((ch & 0xFFFEU) == 0xFFFEU)) && JK_EXPECT_T(ch <= 0x10FFFFU)) { result = sourceIllegal; ch = UNI_REPLACEMENT_CHAR; goto finished; }
1952- if(JK_EXPECT_F(ch == 0U)) { result = sourceIllegal; ch = UNI_REPLACEMENT_CHAR; goto finished; }
1953-
1954- finished:
1955- *u32CodePoint = ch;
1956- return(result);
1957-}
1958-
1959-
1960-static int isLegalUTF8(const UTF8 *source, size_t length) {
1961- const UTF8 *srcptr = source + length;
1962- UTF8 a;
1963-
1964- switch(length) {
1965- default: return(0); // Everything else falls through when "true"...
1966- case 4: if(JK_EXPECT_F(((a = (*--srcptr)) < 0x80) || (a > 0xBF))) { return(0); }
1967- case 3: if(JK_EXPECT_F(((a = (*--srcptr)) < 0x80) || (a > 0xBF))) { return(0); }
1968- case 2: if(JK_EXPECT_F( (a = (*--srcptr)) > 0xBF )) { return(0); }
1969-
1970- switch(*source) { // no fall-through in this inner switch
1971- case 0xE0: if(JK_EXPECT_F(a < 0xA0)) { return(0); } break;
1972- case 0xED: if(JK_EXPECT_F(a > 0x9F)) { return(0); } break;
1973- case 0xF0: if(JK_EXPECT_F(a < 0x90)) { return(0); } break;
1974- case 0xF4: if(JK_EXPECT_F(a > 0x8F)) { return(0); } break;
1975- default: if(JK_EXPECT_F(a < 0x80)) { return(0); }
1976- }
1977-
1978- case 1: if(JK_EXPECT_F((JK_EXPECT_T(*source < 0xC2)) && JK_EXPECT_F(*source >= 0x80))) { return(0); }
1979- }
1980-
1981- if(JK_EXPECT_F(*source > 0xF4)) { return(0); }
1982-
1983- return(1);
1984-}
1985-
1986-static ConversionResult ConvertSingleCodePointInUTF8(const UTF8 *sourceStart, const UTF8 *sourceEnd, UTF8 const **nextUTF8, UTF32 *convertedUTF32) {
1987- ConversionResult result = conversionOK;
1988- const UTF8 *source = sourceStart;
1989- UTF32 ch = 0UL;
1990-
1991-#if !defined(JK_FAST_TRAILING_BYTES)
1992- unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
1993-#else
1994- unsigned short extraBytesToRead = __builtin_clz(((*source)^0xff) << 25);
1995-#endif
1996-
1997- if(JK_EXPECT_F((source + extraBytesToRead + 1) > sourceEnd) || JK_EXPECT_F(!isLegalUTF8(source, extraBytesToRead + 1))) {
1998- source++;
1999- while((source < sourceEnd) && (((*source) & 0xc0) == 0x80) && ((source - sourceStart) < (extraBytesToRead + 1))) { source++; }
2000- NSCParameterAssert(source <= sourceEnd);
2001- result = ((source < sourceEnd) && (((*source) & 0xc0) != 0x80)) ? sourceIllegal : ((sourceStart + extraBytesToRead + 1) > sourceEnd) ? sourceExhausted : sourceIllegal;
2002- ch = UNI_REPLACEMENT_CHAR;
2003- goto finished;
2004- }
2005-
2006- switch(extraBytesToRead) { // The cases all fall through.
2007- case 5: ch += *source++; ch <<= 6;
2008- case 4: ch += *source++; ch <<= 6;
2009- case 3: ch += *source++; ch <<= 6;
2010- case 2: ch += *source++; ch <<= 6;
2011- case 1: ch += *source++; ch <<= 6;
2012- case 0: ch += *source++;
2013- }
2014- ch -= offsetsFromUTF8[extraBytesToRead];
2015-
2016- result = isValidCodePoint(&ch);
2017-
2018- finished:
2019- *nextUTF8 = source;
2020- *convertedUTF32 = ch;
2021-
2022- return(result);
2023-}
2024-
2025-
2026-static ConversionResult ConvertUTF32toUTF8 (UTF32 u32CodePoint, UTF8 **targetStart, UTF8 *targetEnd) {
2027- const UTF32 byteMask = 0xBF, byteMark = 0x80;
2028- ConversionResult result = conversionOK;
2029- UTF8 *target = *targetStart;
2030- UTF32 ch = u32CodePoint;
2031- unsigned short bytesToWrite = 0;
2032-
2033- result = isValidCodePoint(&ch);
2034-
2035- // Figure out how many bytes the result will require. Turn any illegally large UTF32 things (> Plane 17) into replacement chars.
2036- if(ch < (UTF32)0x80) { bytesToWrite = 1; }
2037- else if(ch < (UTF32)0x800) { bytesToWrite = 2; }
2038- else if(ch < (UTF32)0x10000) { bytesToWrite = 3; }
2039- else if(ch <= UNI_MAX_LEGAL_UTF32) { bytesToWrite = 4; }
2040- else { bytesToWrite = 3; ch = UNI_REPLACEMENT_CHAR; result = sourceIllegal; }
2041-
2042- target += bytesToWrite;
2043- if (target > targetEnd) { target -= bytesToWrite; result = targetExhausted; goto finished; }
2044-
2045- switch (bytesToWrite) { // note: everything falls through.
2046- case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
2047- case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
2048- case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
2049- case 1: *--target = (UTF8) (ch | firstByteMark[bytesToWrite]);
2050- }
2051-
2052- target += bytesToWrite;
2053-
2054- finished:
2055- *targetStart = target;
2056- return(result);
2057-}
2058-
2059-JK_STATIC_INLINE int jk_string_add_unicodeCodePoint(JKParseState *parseState, uint32_t unicodeCodePoint, size_t *tokenBufferIdx, JKHash *stringHash) {
2060- UTF8 *u8s = &parseState->token.tokenBuffer.bytes.ptr[*tokenBufferIdx];
2061- ConversionResult result;
2062-
2063- if((result = ConvertUTF32toUTF8(unicodeCodePoint, &u8s, (parseState->token.tokenBuffer.bytes.ptr + parseState->token.tokenBuffer.bytes.length))) != conversionOK) { if(result == targetExhausted) { return(1); } }
2064- size_t utf8len = u8s - &parseState->token.tokenBuffer.bytes.ptr[*tokenBufferIdx], nextIdx = (*tokenBufferIdx) + utf8len;
2065-
2066- while(*tokenBufferIdx < nextIdx) { *stringHash = calculateHash(*stringHash, parseState->token.tokenBuffer.bytes.ptr[(*tokenBufferIdx)++]); }
2067-
2068- return(0);
2069-}
2070-
2071-////////////
2072-#pragma mark -
2073-#pragma mark Decoding / parsing / deserializing functions
2074-
2075-static int jk_parse_string(JKParseState *parseState) {
2076- NSCParameterAssert((parseState != NULL) && (JK_AT_STRING_PTR(parseState) <= JK_END_STRING_PTR(parseState)));
2077- const unsigned char *stringStart = JK_AT_STRING_PTR(parseState) + 1;
2078- const unsigned char *endOfBuffer = JK_END_STRING_PTR(parseState);
2079- const unsigned char *atStringCharacter = stringStart;
2080- unsigned char *tokenBuffer = parseState->token.tokenBuffer.bytes.ptr;
2081- size_t tokenStartIndex = parseState->atIndex;
2082- size_t tokenBufferIdx = 0UL;
2083-
2084- int onlySimpleString = 1, stringState = JSONStringStateStart;
2085- uint16_t escapedUnicode1 = 0U, escapedUnicode2 = 0U;
2086- uint32_t escapedUnicodeCodePoint = 0U;
2087- JKHash stringHash = JK_HASH_INIT;
2088-
2089- while(1) {
2090- unsigned long currentChar;
2091-
2092- if(JK_EXPECT_F(atStringCharacter == endOfBuffer)) { /* XXX Add error message */ stringState = JSONStringStateError; goto finishedParsing; }
2093-
2094- if(JK_EXPECT_F((currentChar = *atStringCharacter++) >= 0x80UL)) {
2095- const unsigned char *nextValidCharacter = NULL;
2096- UTF32 u32ch = 0U;
2097- ConversionResult result;
2098-
2099- if(JK_EXPECT_F((result = ConvertSingleCodePointInUTF8(atStringCharacter - 1, endOfBuffer, (UTF8 const **)&nextValidCharacter, &u32ch)) != conversionOK)) { goto switchToSlowPath; }
2100- stringHash = calculateHash(stringHash, currentChar);
2101- while(atStringCharacter < nextValidCharacter) { NSCParameterAssert(JK_AT_STRING_PTR(parseState) <= JK_END_STRING_PTR(parseState)); stringHash = calculateHash(stringHash, *atStringCharacter++); }
2102- continue;
2103- } else {
2104- if(JK_EXPECT_F(currentChar == (unsigned long)'"')) { stringState = JSONStringStateFinished; goto finishedParsing; }
2105-
2106- if(JK_EXPECT_F(currentChar == (unsigned long)'\\')) {
2107- switchToSlowPath:
2108- onlySimpleString = 0;
2109- stringState = JSONStringStateParsing;
2110- tokenBufferIdx = (atStringCharacter - stringStart) - 1L;
2111- if(JK_EXPECT_F((tokenBufferIdx + 16UL) > parseState->token.tokenBuffer.bytes.length)) { if((tokenBuffer = jk_managedBuffer_resize(&parseState->token.tokenBuffer, tokenBufferIdx + 1024UL)) == NULL) { jk_error(parseState, @"Internal error: Unable to resize temporary buffer. %@ line #%ld", [NSString stringWithUTF8String:__FILE__], (long)__LINE__); stringState = JSONStringStateError; goto finishedParsing; } }
2112- memcpy(tokenBuffer, stringStart, tokenBufferIdx);
2113- goto slowMatch;
2114- }
2115-
2116- if(JK_EXPECT_F(currentChar < 0x20UL)) { jk_error(parseState, @"Invalid character < 0x20 found in string: 0x%2.2x.", currentChar); stringState = JSONStringStateError; goto finishedParsing; }
2117-
2118- stringHash = calculateHash(stringHash, currentChar);
2119- }
2120- }
2121-
2122- slowMatch:
2123-
2124- for(atStringCharacter = (stringStart + ((atStringCharacter - stringStart) - 1L)); (atStringCharacter < endOfBuffer) && (tokenBufferIdx < parseState->token.tokenBuffer.bytes.length); atStringCharacter++) {
2125- if((tokenBufferIdx + 16UL) > parseState->token.tokenBuffer.bytes.length) { if((tokenBuffer = jk_managedBuffer_resize(&parseState->token.tokenBuffer, tokenBufferIdx + 1024UL)) == NULL) { jk_error(parseState, @"Internal error: Unable to resize temporary buffer. %@ line #%ld", [NSString stringWithUTF8String:__FILE__], (long)__LINE__); stringState = JSONStringStateError; goto finishedParsing; } }
2126-
2127- NSCParameterAssert(tokenBufferIdx < parseState->token.tokenBuffer.bytes.length);
2128-
2129- unsigned long currentChar = (*atStringCharacter), escapedChar;
2130-
2131- if(JK_EXPECT_T(stringState == JSONStringStateParsing)) {
2132- if(JK_EXPECT_T(currentChar >= 0x20UL)) {
2133- if(JK_EXPECT_T(currentChar < (unsigned long)0x80)) { // Not a UTF8 sequence
2134- if(JK_EXPECT_F(currentChar == (unsigned long)'"')) { stringState = JSONStringStateFinished; atStringCharacter++; goto finishedParsing; }
2135- if(JK_EXPECT_F(currentChar == (unsigned long)'\\')) { stringState = JSONStringStateEscape; continue; }
2136- stringHash = calculateHash(stringHash, currentChar);
2137- tokenBuffer[tokenBufferIdx++] = currentChar;
2138- continue;
2139- } else { // UTF8 sequence
2140- const unsigned char *nextValidCharacter = NULL;
2141- UTF32 u32ch = 0U;
2142- ConversionResult result;
2143-
2144- if(JK_EXPECT_F((result = ConvertSingleCodePointInUTF8(atStringCharacter, endOfBuffer, (UTF8 const **)&nextValidCharacter, &u32ch)) != conversionOK)) {
2145- if((result == sourceIllegal) && ((parseState->parseOptionFlags & JKParseOptionLooseUnicode) == 0)) { jk_error(parseState, @"Illegal UTF8 sequence found in \"\" string."); stringState = JSONStringStateError; goto finishedParsing; }
2146- if(result == sourceExhausted) { jk_error(parseState, @"End of buffer reached while parsing UTF8 in \"\" string."); stringState = JSONStringStateError; goto finishedParsing; }
2147- if(jk_string_add_unicodeCodePoint(parseState, u32ch, &tokenBufferIdx, &stringHash)) { jk_error(parseState, @"Internal error: Unable to add UTF8 sequence to internal string buffer. %@ line #%ld", [NSString stringWithUTF8String:__FILE__], (long)__LINE__); stringState = JSONStringStateError; goto finishedParsing; }
2148- atStringCharacter = nextValidCharacter - 1;
2149- continue;
2150- } else {
2151- while(atStringCharacter < nextValidCharacter) { tokenBuffer[tokenBufferIdx++] = *atStringCharacter; stringHash = calculateHash(stringHash, *atStringCharacter++); }
2152- atStringCharacter--;
2153- continue;
2154- }
2155- }
2156- } else { // currentChar < 0x20
2157- jk_error(parseState, @"Invalid character < 0x20 found in string: 0x%2.2x.", currentChar); stringState = JSONStringStateError; goto finishedParsing;
2158- }
2159-
2160- } else { // stringState != JSONStringStateParsing
2161- int isSurrogate = 1;
2162-
2163- switch(stringState) {
2164- case JSONStringStateEscape:
2165- switch(currentChar) {
2166- case 'u': escapedUnicode1 = 0U; escapedUnicode2 = 0U; escapedUnicodeCodePoint = 0U; stringState = JSONStringStateEscapedUnicode1; break;
2167-
2168- case 'b': escapedChar = '\b'; goto parsedEscapedChar;
2169- case 'f': escapedChar = '\f'; goto parsedEscapedChar;
2170- case 'n': escapedChar = '\n'; goto parsedEscapedChar;
2171- case 'r': escapedChar = '\r'; goto parsedEscapedChar;
2172- case 't': escapedChar = '\t'; goto parsedEscapedChar;
2173- case '\\': escapedChar = '\\'; goto parsedEscapedChar;
2174- case '/': escapedChar = '/'; goto parsedEscapedChar;
2175- case '"': escapedChar = '"'; goto parsedEscapedChar;
2176-
2177- parsedEscapedChar:
2178- stringState = JSONStringStateParsing;
2179- stringHash = calculateHash(stringHash, escapedChar);
2180- tokenBuffer[tokenBufferIdx++] = escapedChar;
2181- break;
2182-
2183- default: jk_error(parseState, @"Invalid escape sequence found in \"\" string."); stringState = JSONStringStateError; goto finishedParsing; break;
2184- }
2185- break;
2186-
2187- case JSONStringStateEscapedUnicode1:
2188- case JSONStringStateEscapedUnicode2:
2189- case JSONStringStateEscapedUnicode3:
2190- case JSONStringStateEscapedUnicode4: isSurrogate = 0;
2191- case JSONStringStateEscapedUnicodeSurrogate1:
2192- case JSONStringStateEscapedUnicodeSurrogate2:
2193- case JSONStringStateEscapedUnicodeSurrogate3:
2194- case JSONStringStateEscapedUnicodeSurrogate4:
2195- {
2196- uint16_t hexValue = 0U;
2197-
2198- switch(currentChar) {
2199- case '0' ... '9': hexValue = currentChar - '0'; goto parsedHex;
2200- case 'a' ... 'f': hexValue = (currentChar - 'a') + 10U; goto parsedHex;
2201- case 'A' ... 'F': hexValue = (currentChar - 'A') + 10U; goto parsedHex;
2202-
2203- parsedHex:
2204- if(!isSurrogate) { escapedUnicode1 = (escapedUnicode1 << 4) | hexValue; } else { escapedUnicode2 = (escapedUnicode2 << 4) | hexValue; }
2205-
2206- if(stringState == JSONStringStateEscapedUnicode4) {
2207- if(((escapedUnicode1 >= 0xD800U) && (escapedUnicode1 < 0xE000U))) {
2208- if((escapedUnicode1 >= 0xD800U) && (escapedUnicode1 < 0xDC00U)) { stringState = JSONStringStateEscapedNeedEscapeForSurrogate; }
2209- else if((escapedUnicode1 >= 0xDC00U) && (escapedUnicode1 < 0xE000U)) {
2210- if((parseState->parseOptionFlags & JKParseOptionLooseUnicode)) { escapedUnicodeCodePoint = UNI_REPLACEMENT_CHAR; }
2211- else { jk_error(parseState, @"Illegal \\u Unicode escape sequence."); stringState = JSONStringStateError; goto finishedParsing; }
2212- }
2213- }
2214- else { escapedUnicodeCodePoint = escapedUnicode1; }
2215- }
2216-
2217- if(stringState == JSONStringStateEscapedUnicodeSurrogate4) {
2218- if((escapedUnicode2 < 0xdc00) || (escapedUnicode2 > 0xdfff)) {
2219- if((parseState->parseOptionFlags & JKParseOptionLooseUnicode)) { escapedUnicodeCodePoint = UNI_REPLACEMENT_CHAR; }
2220- else { jk_error(parseState, @"Illegal \\u Unicode escape sequence."); stringState = JSONStringStateError; goto finishedParsing; }
2221- }
2222- else { escapedUnicodeCodePoint = ((escapedUnicode1 - 0xd800) * 0x400) + (escapedUnicode2 - 0xdc00) + 0x10000; }
2223- }
2224-
2225- if((stringState == JSONStringStateEscapedUnicode4) || (stringState == JSONStringStateEscapedUnicodeSurrogate4)) {
2226- if((isValidCodePoint(&escapedUnicodeCodePoint) == sourceIllegal) && ((parseState->parseOptionFlags & JKParseOptionLooseUnicode) == 0)) { jk_error(parseState, @"Illegal \\u Unicode escape sequence."); stringState = JSONStringStateError; goto finishedParsing; }
2227- stringState = JSONStringStateParsing;
2228- if(jk_string_add_unicodeCodePoint(parseState, escapedUnicodeCodePoint, &tokenBufferIdx, &stringHash)) { jk_error(parseState, @"Internal error: Unable to add UTF8 sequence to internal string buffer. %@ line #%ld", [NSString stringWithUTF8String:__FILE__], (long)__LINE__); stringState = JSONStringStateError; goto finishedParsing; }
2229- }
2230- else if((stringState >= JSONStringStateEscapedUnicode1) && (stringState <= JSONStringStateEscapedUnicodeSurrogate4)) { stringState++; }
2231- break;
2232-
2233- default: jk_error(parseState, @"Unexpected character found in \\u Unicode escape sequence. Found '%c', expected [0-9a-fA-F].", currentChar); stringState = JSONStringStateError; goto finishedParsing; break;
2234- }
2235- }
2236- break;
2237-
2238- case JSONStringStateEscapedNeedEscapeForSurrogate:
2239- if(currentChar == '\\') { stringState = JSONStringStateEscapedNeedEscapedUForSurrogate; }
2240- else {
2241- if((parseState->parseOptionFlags & JKParseOptionLooseUnicode) == 0) { jk_error(parseState, @"Required a second \\u Unicode escape sequence following a surrogate \\u Unicode escape sequence."); stringState = JSONStringStateError; goto finishedParsing; }
2242- else { stringState = JSONStringStateParsing; atStringCharacter--; if(jk_string_add_unicodeCodePoint(parseState, UNI_REPLACEMENT_CHAR, &tokenBufferIdx, &stringHash)) { jk_error(parseState, @"Internal error: Unable to add UTF8 sequence to internal string buffer. %@ line #%ld", [NSString stringWithUTF8String:__FILE__], (long)__LINE__); stringState = JSONStringStateError; goto finishedParsing; } }
2243- }
2244- break;
2245-
2246- case JSONStringStateEscapedNeedEscapedUForSurrogate:
2247- if(currentChar == 'u') { stringState = JSONStringStateEscapedUnicodeSurrogate1; }
2248- else {
2249- if((parseState->parseOptionFlags & JKParseOptionLooseUnicode) == 0) { jk_error(parseState, @"Required a second \\u Unicode escape sequence following a surrogate \\u Unicode escape sequence."); stringState = JSONStringStateError; goto finishedParsing; }
2250- else { stringState = JSONStringStateParsing; atStringCharacter -= 2; if(jk_string_add_unicodeCodePoint(parseState, UNI_REPLACEMENT_CHAR, &tokenBufferIdx, &stringHash)) { jk_error(parseState, @"Internal error: Unable to add UTF8 sequence to internal string buffer. %@ line #%ld", [NSString stringWithUTF8String:__FILE__], (long)__LINE__); stringState = JSONStringStateError; goto finishedParsing; } }
2251- }
2252- break;
2253-
2254- default: jk_error(parseState, @"Internal error: Unknown stringState. %@ line #%ld", [NSString stringWithUTF8String:__FILE__], (long)__LINE__); stringState = JSONStringStateError; goto finishedParsing; break;
2255- }
2256- }
2257- }
2258-
2259-finishedParsing:
2260-
2261- if(JK_EXPECT_T(stringState == JSONStringStateFinished)) {
2262- NSCParameterAssert((parseState->stringBuffer.bytes.ptr + tokenStartIndex) < atStringCharacter);
2263-
2264- parseState->token.tokenPtrRange.ptr = parseState->stringBuffer.bytes.ptr + tokenStartIndex;
2265- parseState->token.tokenPtrRange.length = (atStringCharacter - parseState->token.tokenPtrRange.ptr);
2266-
2267- if(JK_EXPECT_T(onlySimpleString)) {
2268- NSCParameterAssert(((parseState->token.tokenPtrRange.ptr + 1) < endOfBuffer) && (parseState->token.tokenPtrRange.length >= 2UL) && (((parseState->token.tokenPtrRange.ptr + 1) + (parseState->token.tokenPtrRange.length - 2)) < endOfBuffer));
2269- parseState->token.value.ptrRange.ptr = parseState->token.tokenPtrRange.ptr + 1;
2270- parseState->token.value.ptrRange.length = parseState->token.tokenPtrRange.length - 2UL;
2271- } else {
2272- parseState->token.value.ptrRange.ptr = parseState->token.tokenBuffer.bytes.ptr;
2273- parseState->token.value.ptrRange.length = tokenBufferIdx;
2274- }
2275-
2276- parseState->token.value.hash = stringHash;
2277- parseState->token.value.type = JKValueTypeString;
2278- parseState->atIndex = (atStringCharacter - parseState->stringBuffer.bytes.ptr);
2279- }
2280-
2281- if(JK_EXPECT_F(stringState != JSONStringStateFinished)) { jk_error(parseState, @"Invalid string."); }
2282- return(JK_EXPECT_T(stringState == JSONStringStateFinished) ? 0 : 1);
2283-}
2284-
2285-static int jk_parse_number(JKParseState *parseState) {
2286- NSCParameterAssert((parseState != NULL) && (JK_AT_STRING_PTR(parseState) <= JK_END_STRING_PTR(parseState)));
2287- const unsigned char *numberStart = JK_AT_STRING_PTR(parseState);
2288- const unsigned char *endOfBuffer = JK_END_STRING_PTR(parseState);
2289- const unsigned char *atNumberCharacter = NULL;
2290- int numberState = JSONNumberStateWholeNumberStart, isFloatingPoint = 0, isNegative = 0, backup = 0;
2291- size_t startingIndex = parseState->atIndex;
2292-
2293- for(atNumberCharacter = numberStart; (JK_EXPECT_T(atNumberCharacter < endOfBuffer)) && (JK_EXPECT_T(!(JK_EXPECT_F(numberState == JSONNumberStateFinished) || JK_EXPECT_F(numberState == JSONNumberStateError)))); atNumberCharacter++) {
2294- unsigned long currentChar = (unsigned long)(*atNumberCharacter), lowerCaseCC = currentChar | 0x20UL;
2295-
2296- switch(numberState) {
2297- case JSONNumberStateWholeNumberStart: if (currentChar == '-') { numberState = JSONNumberStateWholeNumberMinus; isNegative = 1; break; }
2298- case JSONNumberStateWholeNumberMinus: if (currentChar == '0') { numberState = JSONNumberStateWholeNumberZero; break; }
2299- else if( (currentChar >= '1') && (currentChar <= '9')) { numberState = JSONNumberStateWholeNumber; break; }
2300- else { /* XXX Add error message */ numberState = JSONNumberStateError; break; }
2301- case JSONNumberStateExponentStart: if( (currentChar == '+') || (currentChar == '-')) { numberState = JSONNumberStateExponentPlusMinus; break; }
2302- case JSONNumberStateFractionalNumberStart:
2303- case JSONNumberStateExponentPlusMinus:if(!((currentChar >= '0') && (currentChar <= '9'))) { /* XXX Add error message */ numberState = JSONNumberStateError; break; }
2304- else { if(numberState == JSONNumberStateFractionalNumberStart) { numberState = JSONNumberStateFractionalNumber; }
2305- else { numberState = JSONNumberStateExponent; } break; }
2306- case JSONNumberStateWholeNumberZero:
2307- case JSONNumberStateWholeNumber: if (currentChar == '.') { numberState = JSONNumberStateFractionalNumberStart; isFloatingPoint = 1; break; }
2308- case JSONNumberStateFractionalNumber: if (lowerCaseCC == 'e') { numberState = JSONNumberStateExponentStart; isFloatingPoint = 1; break; }
2309- case JSONNumberStateExponent: if(!((currentChar >= '0') && (currentChar <= '9')) || (numberState == JSONNumberStateWholeNumberZero)) { numberState = JSONNumberStateFinished; backup = 1; break; }
2310- break;
2311- default: /* XXX Add error message */ numberState = JSONNumberStateError; break;
2312- }
2313- }
2314-
2315- parseState->token.tokenPtrRange.ptr = parseState->stringBuffer.bytes.ptr + startingIndex;
2316- parseState->token.tokenPtrRange.length = (atNumberCharacter - parseState->token.tokenPtrRange.ptr) - backup;
2317- parseState->atIndex = (parseState->token.tokenPtrRange.ptr + parseState->token.tokenPtrRange.length) - parseState->stringBuffer.bytes.ptr;
2318-
2319- if(JK_EXPECT_T(numberState == JSONNumberStateFinished)) {
2320- unsigned char numberTempBuf[parseState->token.tokenPtrRange.length + 4UL];
2321- unsigned char *endOfNumber = NULL;
2322-
2323- memcpy(numberTempBuf, parseState->token.tokenPtrRange.ptr, parseState->token.tokenPtrRange.length);
2324- numberTempBuf[parseState->token.tokenPtrRange.length] = 0;
2325-
2326- errno = 0;
2327-
2328- // Treat "-0" as a floating point number, which is capable of representing negative zeros.
2329- if(JK_EXPECT_F(parseState->token.tokenPtrRange.length == 2UL) && JK_EXPECT_F(numberTempBuf[1] == '0') && JK_EXPECT_F(isNegative)) { isFloatingPoint = 1; }
2330-
2331- if(isFloatingPoint) {
2332- parseState->token.value.number.doubleValue = strtod((const char *)numberTempBuf, (char **)&endOfNumber); // strtod is documented to return U+2261 (identical to) 0.0 on an underflow error (along with setting errno to ERANGE).
2333- parseState->token.value.type = JKValueTypeDouble;
2334- parseState->token.value.ptrRange.ptr = (const unsigned char *)&parseState->token.value.number.doubleValue;
2335- parseState->token.value.ptrRange.length = sizeof(double);
2336- parseState->token.value.hash = (JK_HASH_INIT + parseState->token.value.type);
2337- } else {
2338- if(isNegative) {
2339- parseState->token.value.number.longLongValue = strtoll((const char *)numberTempBuf, (char **)&endOfNumber, 10);
2340- parseState->token.value.type = JKValueTypeLongLong;
2341- parseState->token.value.ptrRange.ptr = (const unsigned char *)&parseState->token.value.number.longLongValue;
2342- parseState->token.value.ptrRange.length = sizeof(long long);
2343- parseState->token.value.hash = (JK_HASH_INIT + parseState->token.value.type) + (JKHash)parseState->token.value.number.longLongValue;
2344- } else {
2345- parseState->token.value.number.unsignedLongLongValue = strtoull((const char *)numberTempBuf, (char **)&endOfNumber, 10);
2346- parseState->token.value.type = JKValueTypeUnsignedLongLong;
2347- parseState->token.value.ptrRange.ptr = (const unsigned char *)&parseState->token.value.number.unsignedLongLongValue;
2348- parseState->token.value.ptrRange.length = sizeof(unsigned long long);
2349- parseState->token.value.hash = (JK_HASH_INIT + parseState->token.value.type) + (JKHash)parseState->token.value.number.unsignedLongLongValue;
2350- }
2351- }
2352-
2353- if(JK_EXPECT_F(errno != 0)) {
2354- numberState = JSONNumberStateError;
2355- if(errno == ERANGE) {
2356- switch(parseState->token.value.type) {
2357- case JKValueTypeDouble: jk_error(parseState, @"The value '%s' could not be represented as a 'double' due to %s.", numberTempBuf, (parseState->token.value.number.doubleValue == 0.0) ? "underflow" : "overflow"); break; // see above for == 0.0.
2358- case JKValueTypeLongLong: jk_error(parseState, @"The value '%s' exceeded the minimum value that could be represented: %lld.", numberTempBuf, parseState->token.value.number.longLongValue); break;
2359- case JKValueTypeUnsignedLongLong: jk_error(parseState, @"The value '%s' exceeded the maximum value that could be represented: %llu.", numberTempBuf, parseState->token.value.number.unsignedLongLongValue); break;
2360- default: jk_error(parseState, @"Internal error: Unknown token value type. %@ line #%ld", [NSString stringWithUTF8String:__FILE__], (long)__LINE__); break;
2361- }
2362- }
2363- }
2364- if(JK_EXPECT_F(endOfNumber != &numberTempBuf[parseState->token.tokenPtrRange.length]) && JK_EXPECT_F(numberState != JSONNumberStateError)) { numberState = JSONNumberStateError; jk_error(parseState, @"The conversion function did not consume all of the number tokens characters."); }
2365-
2366- size_t hashIndex = 0UL;
2367- for(hashIndex = 0UL; hashIndex < parseState->token.value.ptrRange.length; hashIndex++) { parseState->token.value.hash = calculateHash(parseState->token.value.hash, parseState->token.value.ptrRange.ptr[hashIndex]); }
2368- }
2369-
2370- if(JK_EXPECT_F(numberState != JSONNumberStateFinished)) { jk_error(parseState, @"Invalid number."); }
2371- return(JK_EXPECT_T((numberState == JSONNumberStateFinished)) ? 0 : 1);
2372-}
2373-
2374-JK_STATIC_INLINE void jk_set_parsed_token(JKParseState *parseState, const unsigned char *ptr, size_t length, JKTokenType type, size_t advanceBy) {
2375- parseState->token.tokenPtrRange.ptr = ptr;
2376- parseState->token.tokenPtrRange.length = length;
2377- parseState->token.type = type;
2378- parseState->atIndex += advanceBy;
2379-}
2380-
2381-static size_t jk_parse_is_newline(JKParseState *parseState, const unsigned char *atCharacterPtr) {
2382- NSCParameterAssert((parseState != NULL) && (atCharacterPtr != NULL) && (atCharacterPtr >= parseState->stringBuffer.bytes.ptr) && (atCharacterPtr < JK_END_STRING_PTR(parseState)));
2383- const unsigned char *endOfStringPtr = JK_END_STRING_PTR(parseState);
2384-
2385- if(JK_EXPECT_F(atCharacterPtr >= endOfStringPtr)) { return(0UL); }
2386-
2387- if(JK_EXPECT_F((*(atCharacterPtr + 0)) == '\n')) { return(1UL); }
2388- if(JK_EXPECT_F((*(atCharacterPtr + 0)) == '\r')) { if((JK_EXPECT_T((atCharacterPtr + 1) < endOfStringPtr)) && ((*(atCharacterPtr + 1)) == '\n')) { return(2UL); } return(1UL); }
2389- if(parseState->parseOptionFlags & JKParseOptionUnicodeNewlines) {
2390- if((JK_EXPECT_F((*(atCharacterPtr + 0)) == 0xc2)) && (((atCharacterPtr + 1) < endOfStringPtr) && ((*(atCharacterPtr + 1)) == 0x85))) { return(2UL); }
2391- if((JK_EXPECT_F((*(atCharacterPtr + 0)) == 0xe2)) && (((atCharacterPtr + 2) < endOfStringPtr) && ((*(atCharacterPtr + 1)) == 0x80) && (((*(atCharacterPtr + 2)) == 0xa8) || ((*(atCharacterPtr + 2)) == 0xa9)))) { return(3UL); }
2392- }
2393-
2394- return(0UL);
2395-}
2396-
2397-JK_STATIC_INLINE int jk_parse_skip_newline(JKParseState *parseState) {
2398- size_t newlineAdvanceAtIndex = 0UL;
2399- if(JK_EXPECT_F((newlineAdvanceAtIndex = jk_parse_is_newline(parseState, JK_AT_STRING_PTR(parseState))) > 0UL)) { parseState->lineNumber++; parseState->atIndex += (newlineAdvanceAtIndex - 1UL); parseState->lineStartIndex = parseState->atIndex + 1UL; return(1); }
2400- return(0);
2401-}
2402-
2403-JK_STATIC_INLINE void jk_parse_skip_whitespace(JKParseState *parseState) {
2404-#ifndef __clang_analyzer__
2405- NSCParameterAssert((parseState != NULL) && (JK_AT_STRING_PTR(parseState) <= JK_END_STRING_PTR(parseState)));
2406- const unsigned char *atCharacterPtr = NULL;
2407- const unsigned char *endOfStringPtr = JK_END_STRING_PTR(parseState);
2408-
2409- for(atCharacterPtr = JK_AT_STRING_PTR(parseState); (JK_EXPECT_T((atCharacterPtr = JK_AT_STRING_PTR(parseState)) < endOfStringPtr)); parseState->atIndex++) {
2410- if(((*(atCharacterPtr + 0)) == ' ') || ((*(atCharacterPtr + 0)) == '\t')) { continue; }
2411- if(jk_parse_skip_newline(parseState)) { continue; }
2412- if(parseState->parseOptionFlags & JKParseOptionComments) {
2413- if((JK_EXPECT_F((*(atCharacterPtr + 0)) == '/')) && (JK_EXPECT_T((atCharacterPtr + 1) < endOfStringPtr))) {
2414- if((*(atCharacterPtr + 1)) == '/') {
2415- parseState->atIndex++;
2416- for(atCharacterPtr = JK_AT_STRING_PTR(parseState); (JK_EXPECT_T((atCharacterPtr = JK_AT_STRING_PTR(parseState)) < endOfStringPtr)); parseState->atIndex++) { if(jk_parse_skip_newline(parseState)) { break; } }
2417- continue;
2418- }
2419- if((*(atCharacterPtr + 1)) == '*') {
2420- parseState->atIndex++;
2421- for(atCharacterPtr = JK_AT_STRING_PTR(parseState); (JK_EXPECT_T((atCharacterPtr = JK_AT_STRING_PTR(parseState)) < endOfStringPtr)); parseState->atIndex++) {
2422- if(jk_parse_skip_newline(parseState)) { continue; }
2423- if(((*(atCharacterPtr + 0)) == '*') && (((atCharacterPtr + 1) < endOfStringPtr) && ((*(atCharacterPtr + 1)) == '/'))) { parseState->atIndex++; break; }
2424- }
2425- continue;
2426- }
2427- }
2428- }
2429- break;
2430- }
2431-#endif
2432-}
2433-
2434-static int jk_parse_next_token(JKParseState *parseState) {
2435- NSCParameterAssert((parseState != NULL) && (JK_AT_STRING_PTR(parseState) <= JK_END_STRING_PTR(parseState)));
2436- const unsigned char *atCharacterPtr = NULL;
2437- const unsigned char *endOfStringPtr = JK_END_STRING_PTR(parseState);
2438- unsigned char currentCharacter = 0U;
2439- int stopParsing = 0;
2440-
2441- parseState->prev_atIndex = parseState->atIndex;
2442- parseState->prev_lineNumber = parseState->lineNumber;
2443- parseState->prev_lineStartIndex = parseState->lineStartIndex;
2444-
2445- jk_parse_skip_whitespace(parseState);
2446-
2447- if((JK_AT_STRING_PTR(parseState) == endOfStringPtr)) { stopParsing = 1; }
2448-
2449- if((JK_EXPECT_T(stopParsing == 0)) && (JK_EXPECT_T((atCharacterPtr = JK_AT_STRING_PTR(parseState)) < endOfStringPtr))) {
2450- currentCharacter = *atCharacterPtr;
2451-
2452- if(JK_EXPECT_T(currentCharacter == '"')) { if(JK_EXPECT_T((stopParsing = jk_parse_string(parseState)) == 0)) { jk_set_parsed_token(parseState, parseState->token.tokenPtrRange.ptr, parseState->token.tokenPtrRange.length, JKTokenTypeString, 0UL); } }
2453- else if(JK_EXPECT_T(currentCharacter == ':')) { jk_set_parsed_token(parseState, atCharacterPtr, 1UL, JKTokenTypeSeparator, 1UL); }
2454- else if(JK_EXPECT_T(currentCharacter == ',')) { jk_set_parsed_token(parseState, atCharacterPtr, 1UL, JKTokenTypeComma, 1UL); }
2455- else if((JK_EXPECT_T(currentCharacter >= '0') && JK_EXPECT_T(currentCharacter <= '9')) || JK_EXPECT_T(currentCharacter == '-')) { if(JK_EXPECT_T((stopParsing = jk_parse_number(parseState)) == 0)) { jk_set_parsed_token(parseState, parseState->token.tokenPtrRange.ptr, parseState->token.tokenPtrRange.length, JKTokenTypeNumber, 0UL); } }
2456- else if(JK_EXPECT_T(currentCharacter == '{')) { jk_set_parsed_token(parseState, atCharacterPtr, 1UL, JKTokenTypeObjectBegin, 1UL); }
2457- else if(JK_EXPECT_T(currentCharacter == '}')) { jk_set_parsed_token(parseState, atCharacterPtr, 1UL, JKTokenTypeObjectEnd, 1UL); }
2458- else if(JK_EXPECT_T(currentCharacter == '[')) { jk_set_parsed_token(parseState, atCharacterPtr, 1UL, JKTokenTypeArrayBegin, 1UL); }
2459- else if(JK_EXPECT_T(currentCharacter == ']')) { jk_set_parsed_token(parseState, atCharacterPtr, 1UL, JKTokenTypeArrayEnd, 1UL); }
2460-
2461- else if(JK_EXPECT_T(currentCharacter == 't')) { if(!((JK_EXPECT_T((atCharacterPtr + 4UL) < endOfStringPtr)) && (JK_EXPECT_T(atCharacterPtr[1] == 'r')) && (JK_EXPECT_T(atCharacterPtr[2] == 'u')) && (JK_EXPECT_T(atCharacterPtr[3] == 'e')))) { stopParsing = 1; /* XXX Add error message */ } else { jk_set_parsed_token(parseState, atCharacterPtr, 4UL, JKTokenTypeTrue, 4UL); } }
2462- else if(JK_EXPECT_T(currentCharacter == 'f')) { if(!((JK_EXPECT_T((atCharacterPtr + 5UL) < endOfStringPtr)) && (JK_EXPECT_T(atCharacterPtr[1] == 'a')) && (JK_EXPECT_T(atCharacterPtr[2] == 'l')) && (JK_EXPECT_T(atCharacterPtr[3] == 's')) && (JK_EXPECT_T(atCharacterPtr[4] == 'e')))) { stopParsing = 1; /* XXX Add error message */ } else { jk_set_parsed_token(parseState, atCharacterPtr, 5UL, JKTokenTypeFalse, 5UL); } }
2463- else if(JK_EXPECT_T(currentCharacter == 'n')) { if(!((JK_EXPECT_T((atCharacterPtr + 4UL) < endOfStringPtr)) && (JK_EXPECT_T(atCharacterPtr[1] == 'u')) && (JK_EXPECT_T(atCharacterPtr[2] == 'l')) && (JK_EXPECT_T(atCharacterPtr[3] == 'l')))) { stopParsing = 1; /* XXX Add error message */ } else { jk_set_parsed_token(parseState, atCharacterPtr, 4UL, JKTokenTypeNull, 4UL); } }
2464- else { stopParsing = 1; /* XXX Add error message */ }
2465- }
2466-
2467- if(JK_EXPECT_F(stopParsing)) { jk_error(parseState, @"Unexpected token, wanted '{', '}', '[', ']', ',', ':', 'true', 'false', 'null', '\"STRING\"', 'NUMBER'."); }
2468- return(stopParsing);
2469-}
2470-
2471-static void jk_error_parse_accept_or3(JKParseState *parseState, int state, NSString *or1String, NSString *or2String, NSString *or3String) {
2472- NSString *acceptStrings[16];
2473- int acceptIdx = 0;
2474- if(state & JKParseAcceptValue) { acceptStrings[acceptIdx++] = or1String; }
2475- if(state & JKParseAcceptComma) { acceptStrings[acceptIdx++] = or2String; }
2476- if(state & JKParseAcceptEnd) { acceptStrings[acceptIdx++] = or3String; }
2477- if(acceptIdx == 1) { jk_error(parseState, @"Expected %@, not '%*.*s'", acceptStrings[0], (int)parseState->token.tokenPtrRange.length, (int)parseState->token.tokenPtrRange.length, parseState->token.tokenPtrRange.ptr); }
2478- else if(acceptIdx == 2) { jk_error(parseState, @"Expected %@ or %@, not '%*.*s'", acceptStrings[0], acceptStrings[1], (int)parseState->token.tokenPtrRange.length, (int)parseState->token.tokenPtrRange.length, parseState->token.tokenPtrRange.ptr); }
2479- else if(acceptIdx == 3) { jk_error(parseState, @"Expected %@, %@, or %@, not '%*.*s", acceptStrings[0], acceptStrings[1], acceptStrings[2], (int)parseState->token.tokenPtrRange.length, (int)parseState->token.tokenPtrRange.length, parseState->token.tokenPtrRange.ptr); }
2480-}
2481-
2482-static void *jk_parse_array(JKParseState *parseState) {
2483- size_t startingObjectIndex = parseState->objectStack.index;
2484- int arrayState = JKParseAcceptValueOrEnd, stopParsing = 0;
2485- void *parsedArray = NULL;
2486-
2487- while(JK_EXPECT_T((JK_EXPECT_T(stopParsing == 0)) && (JK_EXPECT_T(parseState->atIndex < parseState->stringBuffer.bytes.length)))) {
2488- if(JK_EXPECT_F(parseState->objectStack.index > (parseState->objectStack.count - 4UL))) { if(jk_objectStack_resize(&parseState->objectStack, parseState->objectStack.count + 128UL)) { jk_error(parseState, @"Internal error: [array] objectsIndex > %zu, resize failed? %@ line %#ld", (parseState->objectStack.count - 4UL), [NSString stringWithUTF8String:__FILE__], (long)__LINE__); break; } }
2489-
2490- if(JK_EXPECT_T((stopParsing = jk_parse_next_token(parseState)) == 0)) {
2491- void *object = NULL;
2492-#ifndef NS_BLOCK_ASSERTIONS
2493- parseState->objectStack.objects[parseState->objectStack.index] = NULL;
2494- parseState->objectStack.keys [parseState->objectStack.index] = NULL;
2495-#endif
2496- switch(parseState->token.type) {
2497- case JKTokenTypeNumber:
2498- case JKTokenTypeString:
2499- case JKTokenTypeTrue:
2500- case JKTokenTypeFalse:
2501- case JKTokenTypeNull:
2502- case JKTokenTypeArrayBegin:
2503- case JKTokenTypeObjectBegin:
2504- if(JK_EXPECT_F((arrayState & JKParseAcceptValue) == 0)) { parseState->errorIsPrev = 1; jk_error(parseState, @"Unexpected value."); stopParsing = 1; break; }
2505- if(JK_EXPECT_F((object = jk_object_for_token(parseState)) == NULL)) { jk_error(parseState, @"Internal error: Object == NULL"); stopParsing = 1; break; } else { parseState->objectStack.objects[parseState->objectStack.index++] = object; arrayState = JKParseAcceptCommaOrEnd; }
2506- break;
2507- case JKTokenTypeArrayEnd: if(JK_EXPECT_T(arrayState & JKParseAcceptEnd)) { NSCParameterAssert(parseState->objectStack.index >= startingObjectIndex); parsedArray = (void *)_JKArrayCreate((id *)&parseState->objectStack.objects[startingObjectIndex], (parseState->objectStack.index - startingObjectIndex), parseState->mutableCollections); } else { parseState->errorIsPrev = 1; jk_error(parseState, @"Unexpected ']'."); } stopParsing = 1; break;
2508- case JKTokenTypeComma: if(JK_EXPECT_T(arrayState & JKParseAcceptComma)) { arrayState = JKParseAcceptValue; } else { parseState->errorIsPrev = 1; jk_error(parseState, @"Unexpected ','."); stopParsing = 1; } break;
2509- default: parseState->errorIsPrev = 1; jk_error_parse_accept_or3(parseState, arrayState, @"a value", @"a comma", @"a ']'"); stopParsing = 1; break;
2510- }
2511- }
2512- }
2513-
2514- if(JK_EXPECT_F(parsedArray == NULL)) { size_t idx = 0UL; for(idx = startingObjectIndex; idx < parseState->objectStack.index; idx++) { if(parseState->objectStack.objects[idx] != NULL) { CFRelease(parseState->objectStack.objects[idx]); parseState->objectStack.objects[idx] = NULL; } } }
2515-#if !defined(NS_BLOCK_ASSERTIONS)
2516- else { size_t idx = 0UL; for(idx = startingObjectIndex; idx < parseState->objectStack.index; idx++) { parseState->objectStack.objects[idx] = NULL; parseState->objectStack.keys[idx] = NULL; } }
2517-#endif
2518-
2519- parseState->objectStack.index = startingObjectIndex;
2520- return(parsedArray);
2521-}
2522-
2523-static void *jk_create_dictionary(JKParseState *parseState, size_t startingObjectIndex) {
2524- void *parsedDictionary = NULL;
2525-
2526- parseState->objectStack.index--;
2527-
2528- parsedDictionary = _JKDictionaryCreate((id *)&parseState->objectStack.keys[startingObjectIndex], (NSUInteger *)&parseState->objectStack.cfHashes[startingObjectIndex], (id *)&parseState->objectStack.objects[startingObjectIndex], (parseState->objectStack.index - startingObjectIndex), parseState->mutableCollections);
2529-
2530- return(parsedDictionary);
2531-}
2532-
2533-static void *jk_parse_dictionary(JKParseState *parseState) {
2534- size_t startingObjectIndex = parseState->objectStack.index;
2535- int dictState = JKParseAcceptValueOrEnd, stopParsing = 0;
2536- void *parsedDictionary = NULL;
2537-
2538- while(JK_EXPECT_T((JK_EXPECT_T(stopParsing == 0)) && (JK_EXPECT_T(parseState->atIndex < parseState->stringBuffer.bytes.length)))) {
2539- if(JK_EXPECT_F(parseState->objectStack.index > (parseState->objectStack.count - 4UL))) { if(jk_objectStack_resize(&parseState->objectStack, parseState->objectStack.count + 128UL)) { jk_error(parseState, @"Internal error: [dictionary] objectsIndex > %zu, resize failed? %@ line #%ld", (parseState->objectStack.count - 4UL), [NSString stringWithUTF8String:__FILE__], (long)__LINE__); break; } }
2540-
2541- size_t objectStackIndex = parseState->objectStack.index++;
2542- parseState->objectStack.keys[objectStackIndex] = NULL;
2543- parseState->objectStack.objects[objectStackIndex] = NULL;
2544- void *key = NULL, *object = NULL;
2545-
2546- if(JK_EXPECT_T((JK_EXPECT_T(stopParsing == 0)) && (JK_EXPECT_T((stopParsing = jk_parse_next_token(parseState)) == 0)))) {
2547- switch(parseState->token.type) {
2548- case JKTokenTypeString:
2549- if(JK_EXPECT_F((dictState & JKParseAcceptValue) == 0)) { parseState->errorIsPrev = 1; jk_error(parseState, @"Unexpected string."); stopParsing = 1; break; }
2550- if(JK_EXPECT_F((key = jk_object_for_token(parseState)) == NULL)) { jk_error(parseState, @"Internal error: Key == NULL."); stopParsing = 1; break; }
2551- else {
2552- parseState->objectStack.keys[objectStackIndex] = key;
2553- if(JK_EXPECT_T(parseState->token.value.cacheItem != NULL)) { if(JK_EXPECT_F(parseState->token.value.cacheItem->cfHash == 0UL)) { parseState->token.value.cacheItem->cfHash = CFHash(key); } parseState->objectStack.cfHashes[objectStackIndex] = parseState->token.value.cacheItem->cfHash; }
2554- else { parseState->objectStack.cfHashes[objectStackIndex] = CFHash(key); }
2555- }
2556- break;
2557-
2558- case JKTokenTypeObjectEnd: if((JK_EXPECT_T(dictState & JKParseAcceptEnd))) { NSCParameterAssert(parseState->objectStack.index >= startingObjectIndex); parsedDictionary = jk_create_dictionary(parseState, startingObjectIndex); } else { parseState->errorIsPrev = 1; jk_error(parseState, @"Unexpected '}'."); } stopParsing = 1; break;
2559- case JKTokenTypeComma: if((JK_EXPECT_T(dictState & JKParseAcceptComma))) { dictState = JKParseAcceptValue; parseState->objectStack.index--; continue; } else { parseState->errorIsPrev = 1; jk_error(parseState, @"Unexpected ','."); stopParsing = 1; } break;
2560-
2561- default: parseState->errorIsPrev = 1; jk_error_parse_accept_or3(parseState, dictState, @"a \"STRING\"", @"a comma", @"a '}'"); stopParsing = 1; break;
2562- }
2563- }
2564-
2565- if(JK_EXPECT_T(stopParsing == 0)) {
2566- if(JK_EXPECT_T((stopParsing = jk_parse_next_token(parseState)) == 0)) { if(JK_EXPECT_F(parseState->token.type != JKTokenTypeSeparator)) { parseState->errorIsPrev = 1; jk_error(parseState, @"Expected ':'."); stopParsing = 1; } }
2567- }
2568-
2569- if((JK_EXPECT_T(stopParsing == 0)) && (JK_EXPECT_T((stopParsing = jk_parse_next_token(parseState)) == 0))) {
2570- switch(parseState->token.type) {
2571- case JKTokenTypeNumber:
2572- case JKTokenTypeString:
2573- case JKTokenTypeTrue:
2574- case JKTokenTypeFalse:
2575- case JKTokenTypeNull:
2576- case JKTokenTypeArrayBegin:
2577- case JKTokenTypeObjectBegin:
2578- if(JK_EXPECT_F((dictState & JKParseAcceptValue) == 0)) { parseState->errorIsPrev = 1; jk_error(parseState, @"Unexpected value."); stopParsing = 1; break; }
2579- if(JK_EXPECT_F((object = jk_object_for_token(parseState)) == NULL)) { jk_error(parseState, @"Internal error: Object == NULL."); stopParsing = 1; break; } else { parseState->objectStack.objects[objectStackIndex] = object; dictState = JKParseAcceptCommaOrEnd; }
2580- break;
2581- default: parseState->errorIsPrev = 1; jk_error_parse_accept_or3(parseState, dictState, @"a value", @"a comma", @"a '}'"); stopParsing = 1; break;
2582- }
2583- }
2584- }
2585-
2586- if(JK_EXPECT_F(parsedDictionary == NULL)) { size_t idx = 0UL; for(idx = startingObjectIndex; idx < parseState->objectStack.index; idx++) { if(parseState->objectStack.keys[idx] != NULL) { CFRelease(parseState->objectStack.keys[idx]); parseState->objectStack.keys[idx] = NULL; } if(parseState->objectStack.objects[idx] != NULL) { CFRelease(parseState->objectStack.objects[idx]); parseState->objectStack.objects[idx] = NULL; } } }
2587-#if !defined(NS_BLOCK_ASSERTIONS)
2588- else { size_t idx = 0UL; for(idx = startingObjectIndex; idx < parseState->objectStack.index; idx++) { parseState->objectStack.objects[idx] = NULL; parseState->objectStack.keys[idx] = NULL; } }
2589-#endif
2590-
2591- parseState->objectStack.index = startingObjectIndex;
2592- return(parsedDictionary);
2593-}
2594-
2595-static id json_parse_it(JKParseState *parseState) {
2596- id parsedObject = NULL;
2597- int stopParsing = 0;
2598-
2599- while((JK_EXPECT_T(stopParsing == 0)) && (JK_EXPECT_T(parseState->atIndex < parseState->stringBuffer.bytes.length))) {
2600- if((JK_EXPECT_T(stopParsing == 0)) && (JK_EXPECT_T((stopParsing = jk_parse_next_token(parseState)) == 0))) {
2601- switch(parseState->token.type) {
2602- case JKTokenTypeArrayBegin:
2603- case JKTokenTypeObjectBegin: parsedObject = [(id)jk_object_for_token(parseState) autorelease]; stopParsing = 1; break;
2604- default: jk_error(parseState, @"Expected either '[' or '{'."); stopParsing = 1; break;
2605- }
2606- }
2607- }
2608-
2609- NSCParameterAssert((parseState->objectStack.index == 0) && (JK_AT_STRING_PTR(parseState) <= JK_END_STRING_PTR(parseState)));
2610-
2611- if((parsedObject == NULL) && (JK_AT_STRING_PTR(parseState) == JK_END_STRING_PTR(parseState))) { jk_error(parseState, @"Reached the end of the buffer."); }
2612- if(parsedObject == NULL) { jk_error(parseState, @"Unable to parse JSON."); }
2613-
2614- if((parsedObject != NULL) && (JK_AT_STRING_PTR(parseState) < JK_END_STRING_PTR(parseState))) {
2615- jk_parse_skip_whitespace(parseState);
2616- if((parsedObject != NULL) && ((parseState->parseOptionFlags & JKParseOptionPermitTextAfterValidJSON) == 0) && (JK_AT_STRING_PTR(parseState) < JK_END_STRING_PTR(parseState))) {
2617- jk_error(parseState, @"A valid JSON object was parsed but there were additional non-white-space characters remaining.");
2618- parsedObject = NULL;
2619- }
2620- }
2621-
2622- return(parsedObject);
2623-}
2624-
2625-////////////
2626-#pragma mark -
2627-#pragma mark Object cache
2628-
2629-// This uses a Galois Linear Feedback Shift Register (LFSR) PRNG to pick which item in the cache to age. It has a period of (2^32)-1.
2630-// NOTE: A LFSR *MUST* be initialized to a non-zero value and must always have a non-zero value.
2631-JK_STATIC_INLINE void jk_cache_age(JKParseState *parseState) {
2632- NSCParameterAssert((parseState != NULL) && (parseState->cache.prng_lfsr != 0U));
2633- parseState->cache.prng_lfsr = (parseState->cache.prng_lfsr >> 1) ^ ((0U - (parseState->cache.prng_lfsr & 1U)) & 0x80200003U);
2634- parseState->cache.age[parseState->cache.prng_lfsr & (parseState->cache.count - 1UL)] >>= 1;
2635-}
2636-
2637-// The object cache is nothing more than a hash table with open addressing collision resolution that is bounded by JK_CACHE_PROBES attempts.
2638-//
2639-// The hash table is a linear C array of JKTokenCacheItem. The terms "item" and "bucket" are synonymous with the index in to the cache array, i.e. cache.items[bucket].
2640-//
2641-// Items in the cache have an age associated with them. The age is the number of rightmost 1 bits, i.e. 0000 = 0, 0001 = 1, 0011 = 2, 0111 = 3, 1111 = 4.
2642-// This allows us to use left and right shifts to add or subtract from an items age. Add = (age << 1) | 1. Subtract = age >> 0. Subtract is synonymous with "age" (i.e., age an item).
2643-// The reason for this is it allows us to perform saturated adds and subtractions and is branchless.
2644-// The primitive C type MUST be unsigned. It is currently a "char", which allows (at a minimum and in practice) 8 bits.
2645-//
2646-// A "useable bucket" is a bucket that is not in use (never populated), or has an age == 0.
2647-//
2648-// When an item is found in the cache, it's age is incremented.
2649-// If a useable bucket hasn't been found, the current item (bucket) is aged along with two random items.
2650-//
2651-// If a value is not found in the cache, and no useable bucket has been found, that value is not added to the cache.
2652-
2653-static void *jk_cachedObjects(JKParseState *parseState) {
2654- unsigned long bucket = parseState->token.value.hash & (parseState->cache.count - 1UL), setBucket = 0UL, useableBucket = 0UL, x = 0UL;
2655- void *parsedAtom = NULL;
2656-
2657- if(JK_EXPECT_F(parseState->token.value.ptrRange.length == 0UL) && JK_EXPECT_T(parseState->token.value.type == JKValueTypeString)) { return(@""); }
2658-
2659- for(x = 0UL; x < JK_CACHE_PROBES; x++) {
2660- if(JK_EXPECT_F(parseState->cache.items[bucket].object == NULL)) { setBucket = 1UL; useableBucket = bucket; break; }
2661-
2662- if((JK_EXPECT_T(parseState->cache.items[bucket].hash == parseState->token.value.hash)) && (JK_EXPECT_T(parseState->cache.items[bucket].size == parseState->token.value.ptrRange.length)) && (JK_EXPECT_T(parseState->cache.items[bucket].type == parseState->token.value.type)) && (JK_EXPECT_T(parseState->cache.items[bucket].bytes != NULL)) && (JK_EXPECT_T(strncmp((const char *)parseState->cache.items[bucket].bytes, (const char *)parseState->token.value.ptrRange.ptr, parseState->token.value.ptrRange.length) == 0U))) {
2663- parseState->cache.age[bucket] = (parseState->cache.age[bucket] << 1) | 1U;
2664- parseState->token.value.cacheItem = &parseState->cache.items[bucket];
2665- NSCParameterAssert(parseState->cache.items[bucket].object != NULL);
2666- return((void *)CFRetain(parseState->cache.items[bucket].object));
2667- } else {
2668- if(JK_EXPECT_F(setBucket == 0UL) && JK_EXPECT_F(parseState->cache.age[bucket] == 0U)) { setBucket = 1UL; useableBucket = bucket; }
2669- if(JK_EXPECT_F(setBucket == 0UL)) { parseState->cache.age[bucket] >>= 1; jk_cache_age(parseState); jk_cache_age(parseState); }
2670- // This is the open addressing function. The values length and type are used as a form of "double hashing" to distribute values with the same effective value hash across different object cache buckets.
2671- // The values type is a prime number that is relatively coprime to the other primes in the set of value types and the number of hash table buckets.
2672- bucket = (parseState->token.value.hash + (parseState->token.value.ptrRange.length * (x + 1UL)) + (parseState->token.value.type * (x + 1UL)) + (3UL * (x + 1UL))) & (parseState->cache.count - 1UL);
2673- }
2674- }
2675-
2676- switch(parseState->token.value.type) {
2677- case JKValueTypeString: parsedAtom = (void *)CFStringCreateWithBytes(NULL, parseState->token.value.ptrRange.ptr, parseState->token.value.ptrRange.length, kCFStringEncodingUTF8, 0); break;
2678- case JKValueTypeLongLong: parsedAtom = (void *)CFNumberCreate(NULL, kCFNumberLongLongType, &parseState->token.value.number.longLongValue); break;
2679- case JKValueTypeUnsignedLongLong:
2680- if(parseState->token.value.number.unsignedLongLongValue <= LLONG_MAX) { parsedAtom = (void *)CFNumberCreate(NULL, kCFNumberLongLongType, &parseState->token.value.number.unsignedLongLongValue); }
2681- else { parsedAtom = (void *)parseState->objCImpCache.NSNumberInitWithUnsignedLongLong(parseState->objCImpCache.NSNumberAlloc(parseState->objCImpCache.NSNumberClass, @selector(alloc)), @selector(initWithUnsignedLongLong:), parseState->token.value.number.unsignedLongLongValue); }
2682- break;
2683- case JKValueTypeDouble: parsedAtom = (void *)CFNumberCreate(NULL, kCFNumberDoubleType, &parseState->token.value.number.doubleValue); break;
2684- default: jk_error(parseState, @"Internal error: Unknown token value type. %@ line #%ld", [NSString stringWithUTF8String:__FILE__], (long)__LINE__); break;
2685- }
2686-
2687- if(JK_EXPECT_T(setBucket) && (JK_EXPECT_T(parsedAtom != NULL))) {
2688- bucket = useableBucket;
2689- if(JK_EXPECT_T((parseState->cache.items[bucket].object != NULL))) { CFRelease(parseState->cache.items[bucket].object); parseState->cache.items[bucket].object = NULL; }
2690-
2691- if(JK_EXPECT_T((parseState->cache.items[bucket].bytes = (unsigned char *)reallocf(parseState->cache.items[bucket].bytes, parseState->token.value.ptrRange.length)) != NULL)) {
2692- memcpy(parseState->cache.items[bucket].bytes, parseState->token.value.ptrRange.ptr, parseState->token.value.ptrRange.length);
2693- parseState->cache.items[bucket].object = (void *)CFRetain(parsedAtom);
2694- parseState->cache.items[bucket].hash = parseState->token.value.hash;
2695- parseState->cache.items[bucket].cfHash = 0UL;
2696- parseState->cache.items[bucket].size = parseState->token.value.ptrRange.length;
2697- parseState->cache.items[bucket].type = parseState->token.value.type;
2698- parseState->token.value.cacheItem = &parseState->cache.items[bucket];
2699- parseState->cache.age[bucket] = JK_INIT_CACHE_AGE;
2700- } else { // The realloc failed, so clear the appropriate fields.
2701- parseState->cache.items[bucket].hash = 0UL;
2702- parseState->cache.items[bucket].cfHash = 0UL;
2703- parseState->cache.items[bucket].size = 0UL;
2704- parseState->cache.items[bucket].type = 0UL;
2705- }
2706- }
2707-
2708- return(parsedAtom);
2709-}
2710-
2711-
2712-static void *jk_object_for_token(JKParseState *parseState) {
2713- void *parsedAtom = NULL;
2714-
2715- parseState->token.value.cacheItem = NULL;
2716- switch(parseState->token.type) {
2717- case JKTokenTypeString: parsedAtom = jk_cachedObjects(parseState); break;
2718- case JKTokenTypeNumber: parsedAtom = jk_cachedObjects(parseState); break;
2719- case JKTokenTypeObjectBegin: parsedAtom = jk_parse_dictionary(parseState); break;
2720- case JKTokenTypeArrayBegin: parsedAtom = jk_parse_array(parseState); break;
2721- case JKTokenTypeTrue: parsedAtom = (void *)kCFBooleanTrue; break;
2722- case JKTokenTypeFalse: parsedAtom = (void *)kCFBooleanFalse; break;
2723- case JKTokenTypeNull: parsedAtom = (void *)kCFNull; break;
2724- default: jk_error(parseState, @"Internal error: Unknown token type. %@ line #%ld", [NSString stringWithUTF8String:__FILE__], (long)__LINE__); break;
2725- }
2726-
2727- return(parsedAtom);
2728-}
2729-
2730-#pragma mark -
2731-@implementation JSONDecoder
2732-
2733-+ (id)decoder
2734-{
2735- return([self decoderWithParseOptions:JKParseOptionStrict]);
2736-}
2737-
2738-+ (id)decoderWithParseOptions:(JKParseOptionFlags)parseOptionFlags
2739-{
2740- return([[[self alloc] initWithParseOptions:parseOptionFlags] autorelease]);
2741-}
2742-
2743-- (id)init
2744-{
2745- return([self initWithParseOptions:JKParseOptionStrict]);
2746-}
2747-
2748-- (id)initWithParseOptions:(JKParseOptionFlags)parseOptionFlags
2749-{
2750- if((self = [super init]) == NULL) { return(NULL); }
2751-
2752- if(parseOptionFlags & ~JKParseOptionValidFlags) { [self autorelease]; [NSException raise:NSInvalidArgumentException format:@"Invalid parse options."]; }
2753-
2754- if((parseState = (JKParseState *)calloc(1UL, sizeof(JKParseState))) == NULL) { goto errorExit; }
2755-
2756- parseState->parseOptionFlags = parseOptionFlags;
2757-
2758- parseState->token.tokenBuffer.roundSizeUpToMultipleOf = 4096UL;
2759- parseState->objectStack.roundSizeUpToMultipleOf = 2048UL;
2760-
2761- parseState->objCImpCache.NSNumberClass = _jk_NSNumberClass;
2762- parseState->objCImpCache.NSNumberAlloc = _jk_NSNumberAllocImp;
2763- parseState->objCImpCache.NSNumberInitWithUnsignedLongLong = _jk_NSNumberInitWithUnsignedLongLongImp;
2764-
2765- parseState->cache.prng_lfsr = 1U;
2766- parseState->cache.count = JK_CACHE_SLOTS;
2767- if((parseState->cache.items = (JKTokenCacheItem *)calloc(1UL, sizeof(JKTokenCacheItem) * parseState->cache.count)) == NULL) { goto errorExit; }
2768-
2769- return(self);
2770-
2771- errorExit:
2772- if(self) { [self autorelease]; self = NULL; }
2773- return(NULL);
2774-}
2775-
2776-// This is here primarily to support the NSString and NSData convenience functions so the autoreleased JSONDecoder can release most of its resources before the pool pops.
2777-static void _JSONDecoderCleanup(JSONDecoder *decoder) {
2778- if((decoder != NULL) && (decoder->parseState != NULL)) {
2779- jk_managedBuffer_release(&decoder->parseState->token.tokenBuffer);
2780- jk_objectStack_release(&decoder->parseState->objectStack);
2781-
2782- [decoder clearCache];
2783- if(decoder->parseState->cache.items != NULL) { free(decoder->parseState->cache.items); decoder->parseState->cache.items = NULL; }
2784-
2785- free(decoder->parseState); decoder->parseState = NULL;
2786- }
2787-}
2788-
2789-- (void)dealloc
2790-{
2791- _JSONDecoderCleanup(self);
2792- [super dealloc];
2793-}
2794-
2795-- (void)clearCache
2796-{
2797- if(JK_EXPECT_T(parseState != NULL)) {
2798- if(JK_EXPECT_T(parseState->cache.items != NULL)) {
2799- size_t idx = 0UL;
2800- for(idx = 0UL; idx < parseState->cache.count; idx++) {
2801- if(JK_EXPECT_T(parseState->cache.items[idx].object != NULL)) { CFRelease(parseState->cache.items[idx].object); parseState->cache.items[idx].object = NULL; }
2802- if(JK_EXPECT_T(parseState->cache.items[idx].bytes != NULL)) { free(parseState->cache.items[idx].bytes); parseState->cache.items[idx].bytes = NULL; }
2803- memset(&parseState->cache.items[idx], 0, sizeof(JKTokenCacheItem));
2804- parseState->cache.age[idx] = 0U;
2805- }
2806- }
2807- }
2808-}
2809-
2810-// This needs to be completely rewritten.
2811-static id _JKParseUTF8String(JKParseState *parseState, BOOL mutableCollections, const unsigned char *string, size_t length, NSError **error) {
2812- NSCParameterAssert((parseState != NULL) && (string != NULL) && (parseState->cache.prng_lfsr != 0U));
2813- parseState->stringBuffer.bytes.ptr = string;
2814- parseState->stringBuffer.bytes.length = length;
2815- parseState->atIndex = 0UL;
2816- parseState->lineNumber = 1UL;
2817- parseState->lineStartIndex = 0UL;
2818- parseState->prev_atIndex = 0UL;
2819- parseState->prev_lineNumber = 1UL;
2820- parseState->prev_lineStartIndex = 0UL;
2821- parseState->error = NULL;
2822- parseState->errorIsPrev = 0;
2823- parseState->mutableCollections = (mutableCollections == NO) ? NO : YES;
2824-
2825- unsigned char stackTokenBuffer[JK_TOKENBUFFER_SIZE] JK_ALIGNED(64);
2826- jk_managedBuffer_setToStackBuffer(&parseState->token.tokenBuffer, stackTokenBuffer, sizeof(stackTokenBuffer));
2827-
2828- void *stackObjects [JK_STACK_OBJS] JK_ALIGNED(64);
2829- void *stackKeys [JK_STACK_OBJS] JK_ALIGNED(64);
2830- CFHashCode stackCFHashes[JK_STACK_OBJS] JK_ALIGNED(64);
2831- jk_objectStack_setToStackBuffer(&parseState->objectStack, stackObjects, stackKeys, stackCFHashes, JK_STACK_OBJS);
2832-
2833- id parsedJSON = json_parse_it(parseState);
2834-
2835- if((error != NULL) && (parseState->error != NULL)) { *error = parseState->error; }
2836-
2837- jk_managedBuffer_release(&parseState->token.tokenBuffer);
2838- jk_objectStack_release(&parseState->objectStack);
2839-
2840- parseState->stringBuffer.bytes.ptr = NULL;
2841- parseState->stringBuffer.bytes.length = 0UL;
2842- parseState->atIndex = 0UL;
2843- parseState->lineNumber = 1UL;
2844- parseState->lineStartIndex = 0UL;
2845- parseState->prev_atIndex = 0UL;
2846- parseState->prev_lineNumber = 1UL;
2847- parseState->prev_lineStartIndex = 0UL;
2848- parseState->error = NULL;
2849- parseState->errorIsPrev = 0;
2850- parseState->mutableCollections = NO;
2851-
2852- return(parsedJSON);
2853-}
2854-
2855-////////////
2856-#pragma mark Deprecated as of v1.4
2857-////////////
2858-
2859-// Deprecated in JSONKit v1.4. Use objectWithUTF8String:length: instead.
2860-- (id)parseUTF8String:(const unsigned char *)string length:(size_t)length
2861-{
2862- return([self objectWithUTF8String:string length:length error:NULL]);
2863-}
2864-
2865-// Deprecated in JSONKit v1.4. Use objectWithUTF8String:length:error: instead.
2866-- (id)parseUTF8String:(const unsigned char *)string length:(size_t)length error:(NSError **)error
2867-{
2868- return([self objectWithUTF8String:string length:length error:error]);
2869-}
2870-
2871-// Deprecated in JSONKit v1.4. Use objectWithData: instead.
2872-- (id)parseJSONData:(NSData *)jsonData
2873-{
2874- return([self objectWithData:jsonData error:NULL]);
2875-}
2876-
2877-// Deprecated in JSONKit v1.4. Use objectWithData:error: instead.
2878-- (id)parseJSONData:(NSData *)jsonData error:(NSError **)error
2879-{
2880- return([self objectWithData:jsonData error:error]);
2881-}
2882-
2883-////////////
2884-#pragma mark Methods that return immutable collection objects
2885-////////////
2886-
2887-- (id)objectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length
2888-{
2889- return([self objectWithUTF8String:string length:length error:NULL]);
2890-}
2891-
2892-- (id)objectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length error:(NSError **)error
2893-{
2894- if(parseState == NULL) { [NSException raise:NSInternalInconsistencyException format:@"parseState is NULL."]; }
2895- if(string == NULL) { [NSException raise:NSInvalidArgumentException format:@"The string argument is NULL."]; }
2896-
2897- return(_JKParseUTF8String(parseState, NO, string, (size_t)length, error));
2898-}
2899-
2900-- (id)objectWithData:(NSData *)jsonData
2901-{
2902- return([self objectWithData:jsonData error:NULL]);
2903-}
2904-
2905-- (id)objectWithData:(NSData *)jsonData error:(NSError **)error
2906-{
2907- if(jsonData == NULL) { [NSException raise:NSInvalidArgumentException format:@"The jsonData argument is NULL."]; }
2908- return([self objectWithUTF8String:(const unsigned char *)[jsonData bytes] length:[jsonData length] error:error]);
2909-}
2910-
2911-////////////
2912-#pragma mark Methods that return mutable collection objects
2913-////////////
2914-
2915-- (id)mutableObjectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length
2916-{
2917- return([self mutableObjectWithUTF8String:string length:length error:NULL]);
2918-}
2919-
2920-- (id)mutableObjectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length error:(NSError **)error
2921-{
2922- if(parseState == NULL) { [NSException raise:NSInternalInconsistencyException format:@"parseState is NULL."]; }
2923- if(string == NULL) { [NSException raise:NSInvalidArgumentException format:@"The string argument is NULL."]; }
2924-
2925- return(_JKParseUTF8String(parseState, YES, string, (size_t)length, error));
2926-}
2927-
2928-- (id)mutableObjectWithData:(NSData *)jsonData
2929-{
2930- return([self mutableObjectWithData:jsonData error:NULL]);
2931-}
2932-
2933-- (id)mutableObjectWithData:(NSData *)jsonData error:(NSError **)error
2934-{
2935- if(jsonData == NULL) { [NSException raise:NSInvalidArgumentException format:@"The jsonData argument is NULL."]; }
2936- return([self mutableObjectWithUTF8String:(const unsigned char *)[jsonData bytes] length:[jsonData length] error:error]);
2937-}
2938-
2939-@end
2940-
2941-/*
2942- The NSString and NSData convenience methods need a little bit of explanation.
2943-
2944- Prior to JSONKit v1.4, the NSString -objectFromJSONStringWithParseOptions:error: method looked like
2945-
2946- const unsigned char *utf8String = (const unsigned char *)[self UTF8String];
2947- if(utf8String == NULL) { return(NULL); }
2948- size_t utf8Length = strlen((const char *)utf8String);
2949- return([[JSONDecoder decoderWithParseOptions:parseOptionFlags] parseUTF8String:utf8String length:utf8Length error:error]);
2950-
2951- This changed with v1.4 to a more complicated method. The reason for this is to keep the amount of memory that is
2952- allocated, but not yet freed because it is dependent on the autorelease pool to pop before it can be reclaimed.
2953-
2954- In the simpler v1.3 code, this included all the bytes used to store the -UTF8String along with the JSONDecoder and all its overhead.
2955-
2956- Now we use an autoreleased CFMutableData that is sized to the UTF8 length of the NSString in question and is used to hold the UTF8
2957- conversion of said string.
2958-
2959- Once parsed, the CFMutableData has its length set to 0. This should, hopefully, allow the CFMutableData to realloc and/or free
2960- the buffer.
2961-
2962- Another change made was a slight modification to JSONDecoder so that most of the cleanup work that was done in -dealloc was moved
2963- to a private, internal function. These convenience routines keep the pointer to the autoreleased JSONDecoder and calls
2964- _JSONDecoderCleanup() to early release the decoders resources since we already know that particular decoder is not going to be used
2965- again.
2966-
2967- If everything goes smoothly, this will most likely result in perhaps a few hundred bytes that are allocated but waiting for the
2968- autorelease pool to pop. This is compared to the thousands and easily hundreds of thousands of bytes that would have been in
2969- autorelease limbo. It's more complicated for us, but a win for the user.
2970-
2971- Autorelease objects are used in case things don't go smoothly. By having them autoreleased, we effectively guarantee that our
2972- requirement to -release the object is always met, not matter what goes wrong. The downside is having a an object or two in
2973- autorelease limbo, but we've done our best to minimize that impact, so it all balances out.
2974- */
2975-
2976-@implementation NSString (JSONKitDeserializing)
2977-
2978-static id _NSStringObjectFromJSONString(NSString *jsonString, JKParseOptionFlags parseOptionFlags, NSError **error, BOOL mutableCollection) {
2979- id returnObject = NULL;
2980- CFMutableDataRef mutableData = NULL;
2981- JSONDecoder *decoder = NULL;
2982-
2983- CFIndex stringLength = CFStringGetLength((CFStringRef)jsonString);
2984- NSUInteger stringUTF8Length = [jsonString lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
2985-
2986- if((mutableData = (CFMutableDataRef)[(id)CFDataCreateMutable(NULL, (NSUInteger)stringUTF8Length) autorelease]) != NULL) {
2987- UInt8 *utf8String = CFDataGetMutableBytePtr(mutableData);
2988- CFIndex usedBytes = 0L, convertedCount = 0L;
2989-
2990- convertedCount = CFStringGetBytes((CFStringRef)jsonString, CFRangeMake(0L, stringLength), kCFStringEncodingUTF8, '?', NO, utf8String, (NSUInteger)stringUTF8Length, &usedBytes);
2991- if(JK_EXPECT_F(convertedCount != stringLength) || JK_EXPECT_F(usedBytes < 0L)) { if(error != NULL) { *error = [NSError errorWithDomain:@"JKErrorDomain" code:-1L userInfo:[NSDictionary dictionaryWithObject:@"An error occurred converting the contents of a NSString to UTF8." forKey:NSLocalizedDescriptionKey]]; } goto exitNow; }
2992-
2993- if(mutableCollection == NO) { returnObject = [(decoder = [JSONDecoder decoderWithParseOptions:parseOptionFlags]) objectWithUTF8String:(const unsigned char *)utf8String length:(size_t)usedBytes error:error]; }
2994- else { returnObject = [(decoder = [JSONDecoder decoderWithParseOptions:parseOptionFlags]) mutableObjectWithUTF8String:(const unsigned char *)utf8String length:(size_t)usedBytes error:error]; }
2995- }
2996-
2997-exitNow:
2998- if(mutableData != NULL) { CFDataSetLength(mutableData, 0L); }
2999- if(decoder != NULL) { _JSONDecoderCleanup(decoder); }
3000- return(returnObject);
3001-}
3002-
3003-- (id)objectFromJSONString
3004-{
3005- return([self objectFromJSONStringWithParseOptions:JKParseOptionStrict error:NULL]);
3006-}
3007-
3008-- (id)objectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags
3009-{
3010- return([self objectFromJSONStringWithParseOptions:parseOptionFlags error:NULL]);
3011-}
3012-
3013-- (id)objectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error
3014-{
3015- return(_NSStringObjectFromJSONString(self, parseOptionFlags, error, NO));
3016-}
3017-
3018-
3019-- (id)mutableObjectFromJSONString
3020-{
3021- return([self mutableObjectFromJSONStringWithParseOptions:JKParseOptionStrict error:NULL]);
3022-}
3023-
3024-- (id)mutableObjectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags
3025-{
3026- return([self mutableObjectFromJSONStringWithParseOptions:parseOptionFlags error:NULL]);
3027-}
3028-
3029-- (id)mutableObjectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error
3030-{
3031- return(_NSStringObjectFromJSONString(self, parseOptionFlags, error, YES));
3032-}
3033-
3034-@end
3035-
3036-@implementation NSData (JSONKitDeserializing)
3037-
3038-- (id)objectFromJSONData
3039-{
3040- return([self objectFromJSONDataWithParseOptions:JKParseOptionStrict error:NULL]);
3041-}
3042-
3043-- (id)objectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags
3044-{
3045- return([self objectFromJSONDataWithParseOptions:parseOptionFlags error:NULL]);
3046-}
3047-
3048-- (id)objectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error
3049-{
3050- JSONDecoder *decoder = NULL;
3051- id returnObject = [(decoder = [JSONDecoder decoderWithParseOptions:parseOptionFlags]) objectWithData:self error:error];
3052- if(decoder != NULL) { _JSONDecoderCleanup(decoder); }
3053- return(returnObject);
3054-}
3055-
3056-- (id)mutableObjectFromJSONData
3057-{
3058- return([self mutableObjectFromJSONDataWithParseOptions:JKParseOptionStrict error:NULL]);
3059-}
3060-
3061-- (id)mutableObjectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags
3062-{
3063- return([self mutableObjectFromJSONDataWithParseOptions:parseOptionFlags error:NULL]);
3064-}
3065-
3066-- (id)mutableObjectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error
3067-{
3068- JSONDecoder *decoder = NULL;
3069- id returnObject = [(decoder = [JSONDecoder decoderWithParseOptions:parseOptionFlags]) mutableObjectWithData:self error:error];
3070- if(decoder != NULL) { _JSONDecoderCleanup(decoder); }
3071- return(returnObject);
3072-}
3073-
3074-
3075-@end
3076-
3077-////////////
3078-#pragma mark -
3079-#pragma mark Encoding / deserializing functions
3080-
3081-static void jk_encode_error(JKEncodeState *encodeState, NSString *format, ...) {
3082- NSCParameterAssert((encodeState != NULL) && (format != NULL));
3083-
3084- va_list varArgsList;
3085- va_start(varArgsList, format);
3086- NSString *formatString = [[[NSString alloc] initWithFormat:format arguments:varArgsList] autorelease];
3087- va_end(varArgsList);
3088-
3089- if(encodeState->error == NULL) {
3090- encodeState->error = [NSError errorWithDomain:@"JKErrorDomain" code:-1L userInfo:
3091- [NSDictionary dictionaryWithObjectsAndKeys:
3092- formatString, NSLocalizedDescriptionKey,
3093- NULL]];
3094- }
3095-}
3096-
3097-JK_STATIC_INLINE void jk_encode_updateCache(JKEncodeState *encodeState, JKEncodeCache *cacheSlot, size_t startingAtIndex, id object) {
3098- NSCParameterAssert(encodeState != NULL);
3099- if(JK_EXPECT_T(cacheSlot != NULL)) {
3100- NSCParameterAssert((object != NULL) && (startingAtIndex <= encodeState->atIndex));
3101- cacheSlot->object = object;
3102- cacheSlot->offset = startingAtIndex;
3103- cacheSlot->length = (size_t)(encodeState->atIndex - startingAtIndex);
3104- }
3105-}
3106-
3107-static int jk_encode_printf(JKEncodeState *encodeState, JKEncodeCache *cacheSlot, size_t startingAtIndex, id object, const char *format, ...) {
3108- va_list varArgsList, varArgsListCopy;
3109- va_start(varArgsList, format);
3110- va_copy(varArgsListCopy, varArgsList);
3111-
3112- NSCParameterAssert((encodeState != NULL) && (encodeState->atIndex < encodeState->stringBuffer.bytes.length) && (startingAtIndex <= encodeState->atIndex) && (format != NULL));
3113-
3114- ssize_t formattedStringLength = 0L;
3115- int returnValue = 0;
3116-
3117- if(JK_EXPECT_T((formattedStringLength = vsnprintf((char *)&encodeState->stringBuffer.bytes.ptr[encodeState->atIndex], (encodeState->stringBuffer.bytes.length - encodeState->atIndex), format, varArgsList)) >= (ssize_t)(encodeState->stringBuffer.bytes.length - encodeState->atIndex))) {
3118- NSCParameterAssert(((encodeState->atIndex + (formattedStringLength * 2UL) + 256UL) > encodeState->stringBuffer.bytes.length));
3119- if(JK_EXPECT_F(((encodeState->atIndex + (formattedStringLength * 2UL) + 256UL) > encodeState->stringBuffer.bytes.length)) && JK_EXPECT_F((jk_managedBuffer_resize(&encodeState->stringBuffer, encodeState->atIndex + (formattedStringLength * 2UL)+ 4096UL) == NULL))) { jk_encode_error(encodeState, @"Unable to resize temporary buffer."); returnValue = 1; goto exitNow; }
3120- if(JK_EXPECT_F((formattedStringLength = vsnprintf((char *)&encodeState->stringBuffer.bytes.ptr[encodeState->atIndex], (encodeState->stringBuffer.bytes.length - encodeState->atIndex), format, varArgsListCopy)) >= (ssize_t)(encodeState->stringBuffer.bytes.length - encodeState->atIndex))) { jk_encode_error(encodeState, @"vsnprintf failed unexpectedly."); returnValue = 1; goto exitNow; }
3121- }
3122-
3123-exitNow:
3124- va_end(varArgsList);
3125- va_end(varArgsListCopy);
3126- if(JK_EXPECT_T(returnValue == 0)) { encodeState->atIndex += formattedStringLength; jk_encode_updateCache(encodeState, cacheSlot, startingAtIndex, object); }
3127- return(returnValue);
3128-}
3129-
3130-static int jk_encode_write(JKEncodeState *encodeState, JKEncodeCache *cacheSlot, size_t startingAtIndex, id object, const char *format) {
3131- NSCParameterAssert((encodeState != NULL) && (encodeState->atIndex < encodeState->stringBuffer.bytes.length) && (startingAtIndex <= encodeState->atIndex) && (format != NULL));
3132- if(JK_EXPECT_F(((encodeState->atIndex + strlen(format) + 256UL) > encodeState->stringBuffer.bytes.length)) && JK_EXPECT_F((jk_managedBuffer_resize(&encodeState->stringBuffer, encodeState->atIndex + strlen(format) + 1024UL) == NULL))) { jk_encode_error(encodeState, @"Unable to resize temporary buffer."); return(1); }
3133-
3134- size_t formatIdx = 0UL;
3135- for(formatIdx = 0UL; format[formatIdx] != 0; formatIdx++) { NSCParameterAssert(encodeState->atIndex < encodeState->stringBuffer.bytes.length); encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = format[formatIdx]; }
3136- jk_encode_updateCache(encodeState, cacheSlot, startingAtIndex, object);
3137- return(0);
3138-}
3139-
3140-static int jk_encode_writePrettyPrintWhiteSpace(JKEncodeState *encodeState) {
3141- NSCParameterAssert((encodeState != NULL) && ((encodeState->serializeOptionFlags & JKSerializeOptionPretty) != 0UL));
3142- if(JK_EXPECT_F((encodeState->atIndex + ((encodeState->depth + 1UL) * 2UL) + 16UL) > encodeState->stringBuffer.bytes.length) && JK_EXPECT_T(jk_managedBuffer_resize(&encodeState->stringBuffer, encodeState->atIndex + ((encodeState->depth + 1UL) * 2UL) + 4096UL) == NULL)) { jk_encode_error(encodeState, @"Unable to resize temporary buffer."); return(1); }
3143- encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = '\n';
3144- size_t depthWhiteSpace = 0UL;
3145- for(depthWhiteSpace = 0UL; depthWhiteSpace < (encodeState->depth * 2UL); depthWhiteSpace++) { NSCParameterAssert(encodeState->atIndex < encodeState->stringBuffer.bytes.length); encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = ' '; }
3146- return(0);
3147-}
3148-
3149-static int jk_encode_write1slow(JKEncodeState *encodeState, ssize_t depthChange, const char *format) {
3150- NSCParameterAssert((encodeState != NULL) && (encodeState->atIndex < encodeState->stringBuffer.bytes.length) && (format != NULL) && ((depthChange >= -1L) && (depthChange <= 1L)) && ((encodeState->depth == 0UL) ? (depthChange >= 0L) : 1) && ((encodeState->serializeOptionFlags & JKSerializeOptionPretty) != 0UL));
3151- if(JK_EXPECT_F((encodeState->atIndex + ((encodeState->depth + 1UL) * 2UL) + 16UL) > encodeState->stringBuffer.bytes.length) && JK_EXPECT_F(jk_managedBuffer_resize(&encodeState->stringBuffer, encodeState->atIndex + ((encodeState->depth + 1UL) * 2UL) + 4096UL) == NULL)) { jk_encode_error(encodeState, @"Unable to resize temporary buffer."); return(1); }
3152- encodeState->depth += depthChange;
3153- if(JK_EXPECT_T(format[0] == ':')) { encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = format[0]; encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = ' '; }
3154- else {
3155- if(JK_EXPECT_F(depthChange == -1L)) { if(JK_EXPECT_F(jk_encode_writePrettyPrintWhiteSpace(encodeState))) { return(1); } }
3156- encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = format[0];
3157- if(JK_EXPECT_T(depthChange != -1L)) { if(JK_EXPECT_F(jk_encode_writePrettyPrintWhiteSpace(encodeState))) { return(1); } }
3158- }
3159- NSCParameterAssert(encodeState->atIndex < encodeState->stringBuffer.bytes.length);
3160- return(0);
3161-}
3162-
3163-static int jk_encode_write1fast(JKEncodeState *encodeState, ssize_t depthChange JK_UNUSED_ARG, const char *format) {
3164- NSCParameterAssert((encodeState != NULL) && (encodeState->atIndex < encodeState->stringBuffer.bytes.length) && ((encodeState->serializeOptionFlags & JKSerializeOptionPretty) == 0UL));
3165- if(JK_EXPECT_T((encodeState->atIndex + 4UL) < encodeState->stringBuffer.bytes.length)) { encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = format[0]; }
3166- else { return(jk_encode_write(encodeState, NULL, 0UL, NULL, format)); }
3167- return(0);
3168-}
3169-
3170-static int jk_encode_writen(JKEncodeState *encodeState, JKEncodeCache *cacheSlot, size_t startingAtIndex, id object, const char *format, size_t length) {
3171- NSCParameterAssert((encodeState != NULL) && (encodeState->atIndex < encodeState->stringBuffer.bytes.length) && (startingAtIndex <= encodeState->atIndex));
3172- if(JK_EXPECT_F((encodeState->stringBuffer.bytes.length - encodeState->atIndex) < (length + 4UL))) { if(jk_managedBuffer_resize(&encodeState->stringBuffer, encodeState->atIndex + 4096UL + length) == NULL) { jk_encode_error(encodeState, @"Unable to resize temporary buffer."); return(1); } }
3173- memcpy(encodeState->stringBuffer.bytes.ptr + encodeState->atIndex, format, length);
3174- encodeState->atIndex += length;
3175- jk_encode_updateCache(encodeState, cacheSlot, startingAtIndex, object);
3176- return(0);
3177-}
3178-
3179-JK_STATIC_INLINE JKHash jk_encode_object_hash(void *objectPtr) {
3180- return( ( (((JKHash)objectPtr) >> 21) ^ (((JKHash)objectPtr) >> 9) ) + (((JKHash)objectPtr) >> 4) );
3181-}
3182-
3183-static int jk_encode_add_atom_to_buffer(JKEncodeState *encodeState, void *objectPtr) {
3184- NSCParameterAssert((encodeState != NULL) && (encodeState->atIndex < encodeState->stringBuffer.bytes.length) && (objectPtr != NULL));
3185-
3186- id object = (id)objectPtr, encodeCacheObject = object;
3187- int isClass = JKClassUnknown;
3188- size_t startingAtIndex = encodeState->atIndex;
3189-
3190- JKHash objectHash = jk_encode_object_hash(objectPtr);
3191- JKEncodeCache *cacheSlot = &encodeState->cache[objectHash % JK_ENCODE_CACHE_SLOTS];
3192-
3193- if(JK_EXPECT_T(cacheSlot->object == object)) {
3194- NSCParameterAssert((cacheSlot->object != NULL) &&
3195- (cacheSlot->offset < encodeState->atIndex) && ((cacheSlot->offset + cacheSlot->length) < encodeState->atIndex) &&
3196- (cacheSlot->offset < encodeState->stringBuffer.bytes.length) && ((cacheSlot->offset + cacheSlot->length) < encodeState->stringBuffer.bytes.length) &&
3197- ((encodeState->stringBuffer.bytes.ptr + encodeState->atIndex) < (encodeState->stringBuffer.bytes.ptr + encodeState->stringBuffer.bytes.length)) &&
3198- ((encodeState->stringBuffer.bytes.ptr + cacheSlot->offset) < (encodeState->stringBuffer.bytes.ptr + encodeState->stringBuffer.bytes.length)) &&
3199- ((encodeState->stringBuffer.bytes.ptr + cacheSlot->offset + cacheSlot->length) < (encodeState->stringBuffer.bytes.ptr + encodeState->stringBuffer.bytes.length)));
3200- if(JK_EXPECT_F(((encodeState->atIndex + cacheSlot->length + 256UL) > encodeState->stringBuffer.bytes.length)) && JK_EXPECT_F((jk_managedBuffer_resize(&encodeState->stringBuffer, encodeState->atIndex + cacheSlot->length + 1024UL) == NULL))) { jk_encode_error(encodeState, @"Unable to resize temporary buffer."); return(1); }
3201- NSCParameterAssert(((encodeState->atIndex + cacheSlot->length) < encodeState->stringBuffer.bytes.length) &&
3202- ((encodeState->stringBuffer.bytes.ptr + encodeState->atIndex) < (encodeState->stringBuffer.bytes.ptr + encodeState->stringBuffer.bytes.length)) &&
3203- ((encodeState->stringBuffer.bytes.ptr + encodeState->atIndex + cacheSlot->length) < (encodeState->stringBuffer.bytes.ptr + encodeState->stringBuffer.bytes.length)) &&
3204- ((encodeState->stringBuffer.bytes.ptr + cacheSlot->offset) < (encodeState->stringBuffer.bytes.ptr + encodeState->stringBuffer.bytes.length)) &&
3205- ((encodeState->stringBuffer.bytes.ptr + cacheSlot->offset + cacheSlot->length) < (encodeState->stringBuffer.bytes.ptr + encodeState->stringBuffer.bytes.length)) &&
3206- ((encodeState->stringBuffer.bytes.ptr + cacheSlot->offset + cacheSlot->length) < (encodeState->stringBuffer.bytes.ptr + encodeState->atIndex)));
3207- memcpy(encodeState->stringBuffer.bytes.ptr + encodeState->atIndex, encodeState->stringBuffer.bytes.ptr + cacheSlot->offset, cacheSlot->length);
3208- encodeState->atIndex += cacheSlot->length;
3209- return(0);
3210- }
3211-
3212- // When we encounter a class that we do not handle, and we have either a delegate or block that the user supplied to format unsupported classes,
3213- // we "re-run" the object check. However, we re-run the object check exactly ONCE. If the user supplies an object that isn't one of the
3214- // supported classes, we fail the second type (i.e., double fault error).
3215- BOOL rerunningAfterClassFormatter = NO;
3216-rerunAfterClassFormatter:
3217- if(JK_EXPECT_T(object->isa == encodeState->fastClassLookup.stringClass)) { isClass = JKClassString; }
3218- else if(JK_EXPECT_T(object->isa == encodeState->fastClassLookup.numberClass)) { isClass = JKClassNumber; }
3219- else if(JK_EXPECT_T(object->isa == encodeState->fastClassLookup.dictionaryClass)) { isClass = JKClassDictionary; }
3220- else if(JK_EXPECT_T(object->isa == encodeState->fastClassLookup.arrayClass)) { isClass = JKClassArray; }
3221- else if(JK_EXPECT_T(object->isa == encodeState->fastClassLookup.nullClass)) { isClass = JKClassNull; }
3222- else {
3223- if(JK_EXPECT_T([object isKindOfClass:[NSString class]])) { encodeState->fastClassLookup.stringClass = object->isa; isClass = JKClassString; }
3224- else if(JK_EXPECT_T([object isKindOfClass:[NSNumber class]])) { encodeState->fastClassLookup.numberClass = object->isa; isClass = JKClassNumber; }
3225- else if(JK_EXPECT_T([object isKindOfClass:[NSDictionary class]])) { encodeState->fastClassLookup.dictionaryClass = object->isa; isClass = JKClassDictionary; }
3226- else if(JK_EXPECT_T([object isKindOfClass:[NSArray class]])) { encodeState->fastClassLookup.arrayClass = object->isa; isClass = JKClassArray; }
3227- else if(JK_EXPECT_T([object isKindOfClass:[NSNull class]])) { encodeState->fastClassLookup.nullClass = object->isa; isClass = JKClassNull; }
3228- else {
3229- if((rerunningAfterClassFormatter == NO) && (
3230-#ifdef __BLOCKS__
3231- ((encodeState->classFormatterBlock) && ((object = encodeState->classFormatterBlock(object)) != NULL)) ||
3232-#endif
3233- ((encodeState->classFormatterIMP) && ((object = encodeState->classFormatterIMP(encodeState->classFormatterDelegate, encodeState->classFormatterSelector, object)) != NULL)) )) { rerunningAfterClassFormatter = YES; goto rerunAfterClassFormatter; }
3234-
3235- if(rerunningAfterClassFormatter == NO) { jk_encode_error(encodeState, @"Unable to serialize object class %@.", NSStringFromClass([encodeCacheObject class])); return(1); }
3236- else { jk_encode_error(encodeState, @"Unable to serialize object class %@ that was returned by the unsupported class formatter. Original object class was %@.", (object == NULL) ? @"NULL" : NSStringFromClass([object class]), NSStringFromClass([encodeCacheObject class])); return(1); }
3237- }
3238- }
3239-
3240- // This is here for the benefit of the optimizer. It allows the optimizer to do loop invariant code motion for the JKClassArray
3241- // and JKClassDictionary cases when printing simple, single characters via jk_encode_write(), which is actually a macro:
3242- // #define jk_encode_write1(es, dc, f) (_jk_encode_prettyPrint ? jk_encode_write1slow(es, dc, f) : jk_encode_write1fast(es, dc, f))
3243- int _jk_encode_prettyPrint = JK_EXPECT_T((encodeState->serializeOptionFlags & JKSerializeOptionPretty) == 0) ? 0 : 1;
3244-
3245- switch(isClass) {
3246- case JKClassString:
3247- {
3248- {
3249- const unsigned char *cStringPtr = (const unsigned char *)CFStringGetCStringPtr((CFStringRef)object, kCFStringEncodingMacRoman);
3250- if(cStringPtr != NULL) {
3251- const unsigned char *utf8String = cStringPtr;
3252- size_t utf8Idx = 0UL;
3253-
3254- CFIndex stringLength = CFStringGetLength((CFStringRef)object);
3255- if(JK_EXPECT_F(((encodeState->atIndex + (stringLength * 2UL) + 256UL) > encodeState->stringBuffer.bytes.length)) && JK_EXPECT_F((jk_managedBuffer_resize(&encodeState->stringBuffer, encodeState->atIndex + (stringLength * 2UL) + 1024UL) == NULL))) { jk_encode_error(encodeState, @"Unable to resize temporary buffer."); return(1); }
3256-
3257- if(JK_EXPECT_T((encodeState->encodeOption & JKEncodeOptionStringObjTrimQuotes) == 0UL)) { encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = '\"'; }
3258- for(utf8Idx = 0UL; utf8String[utf8Idx] != 0U; utf8Idx++) {
3259- NSCParameterAssert(((&encodeState->stringBuffer.bytes.ptr[encodeState->atIndex]) - encodeState->stringBuffer.bytes.ptr) < (ssize_t)encodeState->stringBuffer.bytes.length);
3260- NSCParameterAssert(encodeState->atIndex < encodeState->stringBuffer.bytes.length);
3261- if(JK_EXPECT_F(utf8String[utf8Idx] >= 0x80U)) { encodeState->atIndex = startingAtIndex; goto slowUTF8Path; }
3262- if(JK_EXPECT_F(utf8String[utf8Idx] < 0x20U)) {
3263- switch(utf8String[utf8Idx]) {
3264- case '\b': encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = '\\'; encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = 'b'; break;
3265- case '\f': encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = '\\'; encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = 'f'; break;
3266- case '\n': encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = '\\'; encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = 'n'; break;
3267- case '\r': encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = '\\'; encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = 'r'; break;
3268- case '\t': encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = '\\'; encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = 't'; break;
3269- default: if(JK_EXPECT_F(jk_encode_printf(encodeState, NULL, 0UL, NULL, "\\u%4.4x", utf8String[utf8Idx]))) { return(1); } break;
3270- }
3271- } else {
3272- if(JK_EXPECT_F(utf8String[utf8Idx] == '\"') || JK_EXPECT_F(utf8String[utf8Idx] == '\\') || (JK_EXPECT_F(encodeState->serializeOptionFlags & JKSerializeOptionEscapeForwardSlashes) && JK_EXPECT_F(utf8String[utf8Idx] == '/'))) { encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = '\\'; }
3273- encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = utf8String[utf8Idx];
3274- }
3275- }
3276- NSCParameterAssert((encodeState->atIndex + 1UL) < encodeState->stringBuffer.bytes.length);
3277- if(JK_EXPECT_T((encodeState->encodeOption & JKEncodeOptionStringObjTrimQuotes) == 0UL)) { encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = '\"'; }
3278- jk_encode_updateCache(encodeState, cacheSlot, startingAtIndex, encodeCacheObject);
3279- return(0);
3280- }
3281- }
3282-
3283- slowUTF8Path:
3284- {
3285- CFIndex stringLength = CFStringGetLength((CFStringRef)object);
3286- CFIndex maxStringUTF8Length = CFStringGetMaximumSizeForEncoding(stringLength, kCFStringEncodingUTF8) + 32L;
3287-
3288- if(JK_EXPECT_F((size_t)maxStringUTF8Length > encodeState->utf8ConversionBuffer.bytes.length) && JK_EXPECT_F(jk_managedBuffer_resize(&encodeState->utf8ConversionBuffer, maxStringUTF8Length + 1024UL) == NULL)) { jk_encode_error(encodeState, @"Unable to resize temporary buffer."); return(1); }
3289-
3290- CFIndex usedBytes = 0L, convertedCount = 0L;
3291- convertedCount = CFStringGetBytes((CFStringRef)object, CFRangeMake(0L, stringLength), kCFStringEncodingUTF8, '?', NO, encodeState->utf8ConversionBuffer.bytes.ptr, encodeState->utf8ConversionBuffer.bytes.length - 16L, &usedBytes);
3292- if(JK_EXPECT_F(convertedCount != stringLength) || JK_EXPECT_F(usedBytes < 0L)) { jk_encode_error(encodeState, @"An error occurred converting the contents of a NSString to UTF8."); return(1); }
3293-
3294- if(JK_EXPECT_F((encodeState->atIndex + (maxStringUTF8Length * 2UL) + 256UL) > encodeState->stringBuffer.bytes.length) && JK_EXPECT_F(jk_managedBuffer_resize(&encodeState->stringBuffer, encodeState->atIndex + (maxStringUTF8Length * 2UL) + 1024UL) == NULL)) { jk_encode_error(encodeState, @"Unable to resize temporary buffer."); return(1); }
3295-
3296- const unsigned char *utf8String = encodeState->utf8ConversionBuffer.bytes.ptr;
3297-
3298- size_t utf8Idx = 0UL;
3299- if(JK_EXPECT_T((encodeState->encodeOption & JKEncodeOptionStringObjTrimQuotes) == 0UL)) { encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = '\"'; }
3300- for(utf8Idx = 0UL; utf8Idx < (size_t)usedBytes; utf8Idx++) {
3301- NSCParameterAssert(((&encodeState->stringBuffer.bytes.ptr[encodeState->atIndex]) - encodeState->stringBuffer.bytes.ptr) < (ssize_t)encodeState->stringBuffer.bytes.length);
3302- NSCParameterAssert(encodeState->atIndex < encodeState->stringBuffer.bytes.length);
3303- NSCParameterAssert((CFIndex)utf8Idx < usedBytes);
3304- if(JK_EXPECT_F(utf8String[utf8Idx] < 0x20U)) {
3305- switch(utf8String[utf8Idx]) {
3306- case '\b': encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = '\\'; encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = 'b'; break;
3307- case '\f': encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = '\\'; encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = 'f'; break;
3308- case '\n': encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = '\\'; encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = 'n'; break;
3309- case '\r': encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = '\\'; encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = 'r'; break;
3310- case '\t': encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = '\\'; encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = 't'; break;
3311- default: if(JK_EXPECT_F(jk_encode_printf(encodeState, NULL, 0UL, NULL, "\\u%4.4x", utf8String[utf8Idx]))) { return(1); } break;
3312- }
3313- } else {
3314- if(JK_EXPECT_F(utf8String[utf8Idx] >= 0x80U) && (encodeState->serializeOptionFlags & JKSerializeOptionEscapeUnicode)) {
3315- const unsigned char *nextValidCharacter = NULL;
3316- UTF32 u32ch = 0U;
3317- ConversionResult result;
3318-
3319- if(JK_EXPECT_F((result = ConvertSingleCodePointInUTF8(&utf8String[utf8Idx], &utf8String[usedBytes], (UTF8 const **)&nextValidCharacter, &u32ch)) != conversionOK)) { jk_encode_error(encodeState, @"Error converting UTF8."); return(1); }
3320- else {
3321- utf8Idx = (nextValidCharacter - utf8String) - 1UL;
3322- if(JK_EXPECT_T(u32ch <= 0xffffU)) { if(JK_EXPECT_F(jk_encode_printf(encodeState, NULL, 0UL, NULL, "\\u%4.4x", u32ch))) { return(1); } }
3323- else { if(JK_EXPECT_F(jk_encode_printf(encodeState, NULL, 0UL, NULL, "\\u%4.4x\\u%4.4x", (0xd7c0U + (u32ch >> 10)), (0xdc00U + (u32ch & 0x3ffU))))) { return(1); } }
3324- }
3325- } else {
3326- if(JK_EXPECT_F(utf8String[utf8Idx] == '\"') || JK_EXPECT_F(utf8String[utf8Idx] == '\\') || (JK_EXPECT_F(encodeState->serializeOptionFlags & JKSerializeOptionEscapeForwardSlashes) && JK_EXPECT_F(utf8String[utf8Idx] == '/'))) { encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = '\\'; }
3327- encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = utf8String[utf8Idx];
3328- }
3329- }
3330- }
3331- NSCParameterAssert((encodeState->atIndex + 1UL) < encodeState->stringBuffer.bytes.length);
3332- if(JK_EXPECT_T((encodeState->encodeOption & JKEncodeOptionStringObjTrimQuotes) == 0UL)) { encodeState->stringBuffer.bytes.ptr[encodeState->atIndex++] = '\"'; }
3333- jk_encode_updateCache(encodeState, cacheSlot, startingAtIndex, encodeCacheObject);
3334- return(0);
3335- }
3336- }
3337- break;
3338-
3339- case JKClassNumber:
3340- {
3341- if(object == (id)kCFBooleanTrue) { return(jk_encode_writen(encodeState, cacheSlot, startingAtIndex, encodeCacheObject, "true", 4UL)); }
3342- else if(object == (id)kCFBooleanFalse) { return(jk_encode_writen(encodeState, cacheSlot, startingAtIndex, encodeCacheObject, "false", 5UL)); }
3343-
3344- const char *objCType = [object objCType];
3345- char anum[256], *aptr = &anum[255];
3346- int isNegative = 0;
3347- unsigned long long ullv;
3348- long long llv;
3349-
3350- if(JK_EXPECT_F(objCType == NULL) || JK_EXPECT_F(objCType[0] == 0) || JK_EXPECT_F(objCType[1] != 0)) { jk_encode_error(encodeState, @"NSNumber conversion error, unknown type. Type: '%s'", (objCType == NULL) ? "<NULL>" : objCType); return(1); }
3351-
3352- switch(objCType[0]) {
3353- case 'c': case 'i': case 's': case 'l': case 'q':
3354- if(JK_EXPECT_T(CFNumberGetValue((CFNumberRef)object, kCFNumberLongLongType, &llv))) {
3355- if(llv < 0LL) { ullv = -llv; isNegative = 1; } else { ullv = llv; isNegative = 0; }
3356- goto convertNumber;
3357- } else { jk_encode_error(encodeState, @"Unable to get scalar value from number object."); return(1); }
3358- break;
3359- case 'C': case 'I': case 'S': case 'L': case 'Q': case 'B':
3360- if(JK_EXPECT_T(CFNumberGetValue((CFNumberRef)object, kCFNumberLongLongType, &ullv))) {
3361- convertNumber:
3362- if(JK_EXPECT_F(ullv < 10ULL)) { *--aptr = ullv + '0'; } else { while(JK_EXPECT_T(ullv > 0ULL)) { *--aptr = (ullv % 10ULL) + '0'; ullv /= 10ULL; NSCParameterAssert(aptr > anum); } }
3363- if(isNegative) { *--aptr = '-'; }
3364- NSCParameterAssert(aptr > anum);
3365- return(jk_encode_writen(encodeState, cacheSlot, startingAtIndex, encodeCacheObject, aptr, &anum[255] - aptr));
3366- } else { jk_encode_error(encodeState, @"Unable to get scalar value from number object."); return(1); }
3367- break;
3368- case 'f': case 'd':
3369- {
3370- double dv;
3371- if(JK_EXPECT_T(CFNumberGetValue((CFNumberRef)object, kCFNumberDoubleType, &dv))) {
3372- if(JK_EXPECT_F(!isfinite(dv))) { jk_encode_error(encodeState, @"Floating point values must be finite. JSON does not support NaN or Infinity."); return(1); }
3373- return(jk_encode_printf(encodeState, cacheSlot, startingAtIndex, encodeCacheObject, "%.17g", dv));
3374- } else { jk_encode_error(encodeState, @"Unable to get floating point value from number object."); return(1); }
3375- }
3376- break;
3377- default: jk_encode_error(encodeState, @"NSNumber conversion error, unknown type. Type: '%c' / 0x%2.2x", objCType[0], objCType[0]); return(1); break;
3378- }
3379- }
3380- break;
3381-
3382- case JKClassArray:
3383- {
3384- int printComma = 0;
3385- CFIndex arrayCount = CFArrayGetCount((CFArrayRef)object), idx = 0L;
3386- if(JK_EXPECT_F(jk_encode_write1(encodeState, 1L, "["))) { return(1); }
3387- if(JK_EXPECT_F(arrayCount > 1020L)) {
3388- for(id arrayObject in object) { if(JK_EXPECT_T(printComma)) { if(JK_EXPECT_F(jk_encode_write1(encodeState, 0L, ","))) { return(1); } } printComma = 1; if(JK_EXPECT_F(jk_encode_add_atom_to_buffer(encodeState, arrayObject))) { return(1); } }
3389- } else {
3390- void *objects[1024];
3391- CFArrayGetValues((CFArrayRef)object, CFRangeMake(0L, arrayCount), (const void **)objects);
3392- for(idx = 0L; idx < arrayCount; idx++) { if(JK_EXPECT_T(printComma)) { if(JK_EXPECT_F(jk_encode_write1(encodeState, 0L, ","))) { return(1); } } printComma = 1; if(JK_EXPECT_F(jk_encode_add_atom_to_buffer(encodeState, objects[idx]))) { return(1); } }
3393- }
3394- return(jk_encode_write1(encodeState, -1L, "]"));
3395- }
3396- break;
3397-
3398- case JKClassDictionary:
3399- {
3400- int printComma = 0;
3401- CFIndex dictionaryCount = CFDictionaryGetCount((CFDictionaryRef)object), idx = 0L;
3402- id enumerateObject = JK_EXPECT_F(_jk_encode_prettyPrint) ? [[object allKeys] sortedArrayUsingSelector:@selector(compare:)] : object;
3403-
3404- if(JK_EXPECT_F(jk_encode_write1(encodeState, 1L, "{"))) { return(1); }
3405- if(JK_EXPECT_F(_jk_encode_prettyPrint) || JK_EXPECT_F(dictionaryCount > 1020L)) {
3406- for(id keyObject in enumerateObject) {
3407- if(JK_EXPECT_T(printComma)) { if(JK_EXPECT_F(jk_encode_write1(encodeState, 0L, ","))) { return(1); } }
3408- printComma = 1;
3409- if(JK_EXPECT_F((keyObject->isa != encodeState->fastClassLookup.stringClass)) && JK_EXPECT_F(([keyObject isKindOfClass:[NSString class]] == NO))) { jk_encode_error(encodeState, @"Key must be a string object."); return(1); }
3410- if(JK_EXPECT_F(jk_encode_add_atom_to_buffer(encodeState, keyObject))) { return(1); }
3411- if(JK_EXPECT_F(jk_encode_write1(encodeState, 0L, ":"))) { return(1); }
3412- if(JK_EXPECT_F(jk_encode_add_atom_to_buffer(encodeState, (void *)CFDictionaryGetValue((CFDictionaryRef)object, keyObject)))) { return(1); }
3413- }
3414- } else {
3415- void *keys[1024], *objects[1024];
3416- CFDictionaryGetKeysAndValues((CFDictionaryRef)object, (const void **)keys, (const void **)objects);
3417- for(idx = 0L; idx < dictionaryCount; idx++) {
3418- if(JK_EXPECT_T(printComma)) { if(JK_EXPECT_F(jk_encode_write1(encodeState, 0L, ","))) { return(1); } }
3419- printComma = 1;
3420- if(JK_EXPECT_F(((id)keys[idx])->isa != encodeState->fastClassLookup.stringClass) && JK_EXPECT_F([(id)keys[idx] isKindOfClass:[NSString class]] == NO)) { jk_encode_error(encodeState, @"Key must be a string object."); return(1); }
3421- if(JK_EXPECT_F(jk_encode_add_atom_to_buffer(encodeState, keys[idx]))) { return(1); }
3422- if(JK_EXPECT_F(jk_encode_write1(encodeState, 0L, ":"))) { return(1); }
3423- if(JK_EXPECT_F(jk_encode_add_atom_to_buffer(encodeState, objects[idx]))) { return(1); }
3424- }
3425- }
3426- return(jk_encode_write1(encodeState, -1L, "}"));
3427- }
3428- break;
3429-
3430- case JKClassNull: return(jk_encode_writen(encodeState, cacheSlot, startingAtIndex, encodeCacheObject, "null", 4UL)); break;
3431-
3432- default: jk_encode_error(encodeState, @"Unable to serialize object class %@.", NSStringFromClass([object class])); return(1); break;
3433- }
3434-
3435- return(0);
3436-}
3437-
3438-
3439-@implementation JKSerializer
3440-
3441-+ (id)serializeObject:(id)object options:(JKSerializeOptionFlags)optionFlags encodeOption:(JKEncodeOptionType)encodeOption block:(JKSERIALIZER_BLOCKS_PROTO)block delegate:(id)delegate selector:(SEL)selector error:(NSError **)error
3442-{
3443- return([[[[self alloc] init] autorelease] serializeObject:object options:optionFlags encodeOption:encodeOption block:block delegate:delegate selector:selector error:error]);
3444-}
3445-
3446-- (id)serializeObject:(id)object options:(JKSerializeOptionFlags)optionFlags encodeOption:(JKEncodeOptionType)encodeOption block:(JKSERIALIZER_BLOCKS_PROTO)block delegate:(id)delegate selector:(SEL)selector error:(NSError **)error
3447-{
3448-#ifndef __BLOCKS__
3449-#pragma unused(block)
3450-#endif
3451- NSParameterAssert((object != NULL) && (encodeState == NULL) && ((delegate != NULL) ? (block == NULL) : 1) && ((block != NULL) ? (delegate == NULL) : 1) &&
3452- (((encodeOption & JKEncodeOptionCollectionObj) != 0UL) ? (((encodeOption & JKEncodeOptionStringObj) == 0UL) && ((encodeOption & JKEncodeOptionStringObjTrimQuotes) == 0UL)) : 1) &&
3453- (((encodeOption & JKEncodeOptionStringObj) != 0UL) ? ((encodeOption & JKEncodeOptionCollectionObj) == 0UL) : 1));
3454-
3455- id returnObject = NULL;
3456-
3457- if(encodeState != NULL) { [self releaseState]; }
3458- if((encodeState = (struct JKEncodeState *)calloc(1UL, sizeof(JKEncodeState))) == NULL) { [NSException raise:NSMallocException format:@"Unable to allocate state structure."]; return(NULL); }
3459-
3460- if((error != NULL) && (*error != NULL)) { *error = NULL; }
3461-
3462- if(delegate != NULL) {
3463- if(selector == NULL) { [NSException raise:NSInvalidArgumentException format:@"The delegate argument is not NULL, but the selector argument is NULL."]; }
3464- if([delegate respondsToSelector:selector] == NO) { [NSException raise:NSInvalidArgumentException format:@"The serializeUnsupportedClassesUsingDelegate: delegate does not respond to the selector argument."]; }
3465- encodeState->classFormatterDelegate = delegate;
3466- encodeState->classFormatterSelector = selector;
3467- encodeState->classFormatterIMP = (JKClassFormatterIMP)[delegate methodForSelector:selector];
3468- NSCParameterAssert(encodeState->classFormatterIMP != NULL);
3469- }
3470-
3471-#ifdef __BLOCKS__
3472- encodeState->classFormatterBlock = block;
3473-#endif
3474- encodeState->serializeOptionFlags = optionFlags;
3475- encodeState->encodeOption = encodeOption;
3476- encodeState->stringBuffer.roundSizeUpToMultipleOf = (1024UL * 32UL);
3477- encodeState->utf8ConversionBuffer.roundSizeUpToMultipleOf = 4096UL;
3478-
3479- unsigned char stackJSONBuffer[JK_JSONBUFFER_SIZE] JK_ALIGNED(64);
3480- jk_managedBuffer_setToStackBuffer(&encodeState->stringBuffer, stackJSONBuffer, sizeof(stackJSONBuffer));
3481-
3482- unsigned char stackUTF8Buffer[JK_UTF8BUFFER_SIZE] JK_ALIGNED(64);
3483- jk_managedBuffer_setToStackBuffer(&encodeState->utf8ConversionBuffer, stackUTF8Buffer, sizeof(stackUTF8Buffer));
3484-
3485- if(((encodeOption & JKEncodeOptionCollectionObj) != 0UL) && (([object isKindOfClass:[NSArray class]] == NO) && ([object isKindOfClass:[NSDictionary class]] == NO))) { jk_encode_error(encodeState, @"Unable to serialize object class %@, expected a NSArray or NSDictionary.", NSStringFromClass([object class])); goto errorExit; }
3486- if(((encodeOption & JKEncodeOptionStringObj) != 0UL) && ([object isKindOfClass:[NSString class]] == NO)) { jk_encode_error(encodeState, @"Unable to serialize object class %@, expected a NSString.", NSStringFromClass([object class])); goto errorExit; }
3487-
3488- if(jk_encode_add_atom_to_buffer(encodeState, object) == 0) {
3489- BOOL stackBuffer = ((encodeState->stringBuffer.flags & JKManagedBufferMustFree) == 0UL) ? YES : NO;
3490-
3491- if((encodeState->atIndex < 2UL))
3492- if((stackBuffer == NO) && ((encodeState->stringBuffer.bytes.ptr = (unsigned char *)reallocf(encodeState->stringBuffer.bytes.ptr, encodeState->atIndex + 16UL)) == NULL)) { jk_encode_error(encodeState, @"Unable to realloc buffer"); goto errorExit; }
3493-
3494- switch((encodeOption & JKEncodeOptionAsTypeMask)) {
3495- case JKEncodeOptionAsData:
3496- if(stackBuffer == YES) { if((returnObject = [(id)CFDataCreate( NULL, encodeState->stringBuffer.bytes.ptr, (CFIndex)encodeState->atIndex) autorelease]) == NULL) { jk_encode_error(encodeState, @"Unable to create NSData object"); } }
3497- else { if((returnObject = [(id)CFDataCreateWithBytesNoCopy( NULL, encodeState->stringBuffer.bytes.ptr, (CFIndex)encodeState->atIndex, NULL) autorelease]) == NULL) { jk_encode_error(encodeState, @"Unable to create NSData object"); } }
3498- break;
3499-
3500- case JKEncodeOptionAsString:
3501- if(stackBuffer == YES) { if((returnObject = [(id)CFStringCreateWithBytes( NULL, (const UInt8 *)encodeState->stringBuffer.bytes.ptr, (CFIndex)encodeState->atIndex, kCFStringEncodingUTF8, NO) autorelease]) == NULL) { jk_encode_error(encodeState, @"Unable to create NSString object"); } }
3502- else { if((returnObject = [(id)CFStringCreateWithBytesNoCopy(NULL, (const UInt8 *)encodeState->stringBuffer.bytes.ptr, (CFIndex)encodeState->atIndex, kCFStringEncodingUTF8, NO, NULL) autorelease]) == NULL) { jk_encode_error(encodeState, @"Unable to create NSString object"); } }
3503- break;
3504-
3505- default: jk_encode_error(encodeState, @"Unknown encode as type."); break;
3506- }
3507-
3508- if((returnObject != NULL) && (stackBuffer == NO)) { encodeState->stringBuffer.flags &= ~JKManagedBufferMustFree; encodeState->stringBuffer.bytes.ptr = NULL; encodeState->stringBuffer.bytes.length = 0UL; }
3509- }
3510-
3511-errorExit:
3512- if((encodeState != NULL) && (error != NULL) && (encodeState->error != NULL)) { *error = encodeState->error; encodeState->error = NULL; }
3513- [self releaseState];
3514-
3515- return(returnObject);
3516-}
3517-
3518-- (void)releaseState
3519-{
3520- if(encodeState != NULL) {
3521- jk_managedBuffer_release(&encodeState->stringBuffer);
3522- jk_managedBuffer_release(&encodeState->utf8ConversionBuffer);
3523- free(encodeState); encodeState = NULL;
3524- }
3525-}
3526-
3527-- (void)dealloc
3528-{
3529- [self releaseState];
3530- [super dealloc];
3531-}
3532-
3533-@end
3534-
3535-@implementation NSString (JSONKitSerializing)
3536-
3537-////////////
3538-#pragma mark Methods for serializing a single NSString.
3539-////////////
3540-
3541-// Useful for those who need to serialize just a NSString. Otherwise you would have to do something like [NSArray arrayWithObject:stringToBeJSONSerialized], serializing the array, and then chopping of the extra ^\[.*\]$ square brackets.
3542-
3543-// NSData returning methods...
3544-
3545-- (NSData *)JSONData
3546-{
3547- return([self JSONDataWithOptions:JKSerializeOptionNone includeQuotes:YES error:NULL]);
3548-}
3549-
3550-- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions includeQuotes:(BOOL)includeQuotes error:(NSError **)error
3551-{
3552- return([JKSerializer serializeObject:self options:serializeOptions encodeOption:(JKEncodeOptionAsData | ((includeQuotes == NO) ? JKEncodeOptionStringObjTrimQuotes : 0UL) | JKEncodeOptionStringObj) block:NULL delegate:NULL selector:NULL error:error]);
3553-}
3554-
3555-// NSString returning methods...
3556-
3557-- (NSString *)JSONString
3558-{
3559- return([self JSONStringWithOptions:JKSerializeOptionNone includeQuotes:YES error:NULL]);
3560-}
3561-
3562-- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions includeQuotes:(BOOL)includeQuotes error:(NSError **)error
3563-{
3564- return([JKSerializer serializeObject:self options:serializeOptions encodeOption:(JKEncodeOptionAsString | ((includeQuotes == NO) ? JKEncodeOptionStringObjTrimQuotes : 0UL) | JKEncodeOptionStringObj) block:NULL delegate:NULL selector:NULL error:error]);
3565-}
3566-
3567-@end
3568-
3569-@implementation NSArray (JSONKitSerializing)
3570-
3571-// NSData returning methods...
3572-
3573-- (NSData *)JSONData
3574-{
3575- return([JKSerializer serializeObject:self options:JKSerializeOptionNone encodeOption:(JKEncodeOptionAsData | JKEncodeOptionCollectionObj) block:NULL delegate:NULL selector:NULL error:NULL]);
3576-}
3577-
3578-- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error
3579-{
3580- return([JKSerializer serializeObject:self options:serializeOptions encodeOption:(JKEncodeOptionAsData | JKEncodeOptionCollectionObj) block:NULL delegate:NULL selector:NULL error:error]);
3581-}
3582-
3583-- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error
3584-{
3585- return([JKSerializer serializeObject:self options:serializeOptions encodeOption:(JKEncodeOptionAsData | JKEncodeOptionCollectionObj) block:NULL delegate:delegate selector:selector error:error]);
3586-}
3587-
3588-// NSString returning methods...
3589-
3590-- (NSString *)JSONString
3591-{
3592- return([JKSerializer serializeObject:self options:JKSerializeOptionNone encodeOption:(JKEncodeOptionAsString | JKEncodeOptionCollectionObj) block:NULL delegate:NULL selector:NULL error:NULL]);
3593-}
3594-
3595-- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error
3596-{
3597- return([JKSerializer serializeObject:self options:serializeOptions encodeOption:(JKEncodeOptionAsString | JKEncodeOptionCollectionObj) block:NULL delegate:NULL selector:NULL error:error]);
3598-}
3599-
3600-- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error
3601-{
3602- return([JKSerializer serializeObject:self options:serializeOptions encodeOption:(JKEncodeOptionAsString | JKEncodeOptionCollectionObj) block:NULL delegate:delegate selector:selector error:error]);
3603-}
3604-
3605-@end
3606-
3607-@implementation NSDictionary (JSONKitSerializing)
3608-
3609-// NSData returning methods...
3610-
3611-- (NSData *)JSONData
3612-{
3613- return([JKSerializer serializeObject:self options:JKSerializeOptionNone encodeOption:(JKEncodeOptionAsData | JKEncodeOptionCollectionObj) block:NULL delegate:NULL selector:NULL error:NULL]);
3614-}
3615-
3616-- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error
3617-{
3618- return([JKSerializer serializeObject:self options:serializeOptions encodeOption:(JKEncodeOptionAsData | JKEncodeOptionCollectionObj) block:NULL delegate:NULL selector:NULL error:error]);
3619-}
3620-
3621-- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error
3622-{
3623- return([JKSerializer serializeObject:self options:serializeOptions encodeOption:(JKEncodeOptionAsData | JKEncodeOptionCollectionObj) block:NULL delegate:delegate selector:selector error:error]);
3624-}
3625-
3626-// NSString returning methods...
3627-
3628-- (NSString *)JSONString
3629-{
3630- return([JKSerializer serializeObject:self options:JKSerializeOptionNone encodeOption:(JKEncodeOptionAsString | JKEncodeOptionCollectionObj) block:NULL delegate:NULL selector:NULL error:NULL]);
3631-}
3632-
3633-- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error
3634-{
3635- return([JKSerializer serializeObject:self options:serializeOptions encodeOption:(JKEncodeOptionAsString | JKEncodeOptionCollectionObj) block:NULL delegate:NULL selector:NULL error:error]);
3636-}
3637-
3638-- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error
3639-{
3640- return([JKSerializer serializeObject:self options:serializeOptions encodeOption:(JKEncodeOptionAsString | JKEncodeOptionCollectionObj) block:NULL delegate:delegate selector:selector error:error]);
3641-}
3642-
3643-@end
3644-
3645-
3646-#ifdef __BLOCKS__
3647-
3648-@implementation NSArray (JSONKitSerializingBlockAdditions)
3649-
3650-- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error
3651-{
3652- return([JKSerializer serializeObject:self options:serializeOptions encodeOption:(JKEncodeOptionAsData | JKEncodeOptionCollectionObj) block:block delegate:NULL selector:NULL error:error]);
3653-}
3654-
3655-- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error
3656-{
3657- return([JKSerializer serializeObject:self options:serializeOptions encodeOption:(JKEncodeOptionAsString | JKEncodeOptionCollectionObj) block:block delegate:NULL selector:NULL error:error]);
3658-}
3659-
3660-@end
3661-
3662-@implementation NSDictionary (JSONKitSerializingBlockAdditions)
3663-
3664-- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error
3665-{
3666- return([JKSerializer serializeObject:self options:serializeOptions encodeOption:(JKEncodeOptionAsData | JKEncodeOptionCollectionObj) block:block delegate:NULL selector:NULL error:error]);
3667-}
3668-
3669-- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error
3670-{
3671- return([JKSerializer serializeObject:self options:serializeOptions encodeOption:(JKEncodeOptionAsString | JKEncodeOptionCollectionObj) block:block delegate:NULL selector:NULL error:error]);
3672-}
3673-
3674-@end
3675-
3676-#endif // __BLOCKS__
3677-
3678
3679=== removed file 'Dependencies/JSONKit/README.md'
3680--- Dependencies/JSONKit/README.md 2011-08-31 14:56:30 +0000
3681+++ Dependencies/JSONKit/README.md 1970-01-01 00:00:00 +0000
3682@@ -1,307 +0,0 @@
3683-# JSONKit
3684-
3685-JSONKit is dual licensed under either the terms of the BSD License, or alternatively under the terms of the Apache License, Version 2.0.<br />
3686-Copyright &copy; 2011, John Engelhart.
3687-
3688-### A Very High Performance Objective-C JSON Library
3689-
3690- Parsing | Serializing
3691-:---------:|:-------------:
3692-<img src="http://chart.googleapis.com/chart?chf=a,s,000000%7Cb0,lg,0,6589C760,0,6589C7B4,1%7Cbg,lg,90,EFEFEF,0,F8F8F8,1&chxl=0:%7CTouchJSON%7CXML+.plist%7Cjson-framework%7CYAJL-ObjC%7Cgzip+JSONKit%7CBinary+.plist%7CJSONKit%7C2:%7CTime+to+Deserialize+in+%C2%B5sec&chxp=2,40&chxr=0,0,5%7C1,0,3250&chxs=0,676767,11.5,1,lt,676767&chxt=y,x,x&chbh=a,5,4&chs=350x185&cht=bhs&chco=6589C783&chds=0,3250&chd=t:410.517,510.262,539.614,1351.257,1683.346,1747.953,2955.881&chg=-1,0,1,3&chm=N+*s*+%C2%B5s,676767,0,0:5,10.5%7CN+*s*+%C2%B5s,3d3d3d,0,6,10.5,,r:-5:1&chem=y;s=text_outline;d=666,10.5,l,fff,_,Decompress+%2b+Parse+is+just;ds=0;dp=2;py=0;of=58,7%7Cy;s=text_outline;d=666,10.5,l,fff,_,5.6%25+slower+than+Binary+.plist%21;ds=0;dp=2;py=0;of=53,-5" width="350" height="185" alt="Deserialize from JSON" /> | <img src="http://chart.googleapis.com/chart?chf=a,s,000000%7Cb0,lg,0,699E7260,0,699E72B4,1%7Cbg,lg,90,EFEFEF,0,F8F8F8,1&chxl=0:%7CTouchJSON%7CYAJL-ObjC%7CXML+.plist%7Cjson-framework%7CBinary+.plist%7Cgzip+JSONKit%7CJSONKit%7C2:%7CTime+to+Serialize+in+%C2%B5sec&chxp=2,40&chxr=0,0,5%7C1,0,3250&chxs=0,676767,11.5,1,lt,676767&chxt=y,x,x&chbh=a,5,4&chs=350x175&cht=bhs&chco=699E7284&chds=0,3250&chd=t:96.387,466.947,626.153,1028.432,1945.511,2156.978,3051.976&chg=-1,0,1,3&chm=N+*s*+%C2%B5s,676767,0,0:5,10.5%7CN+*s*+%C2%B5s,4d4d4d,0,6,10.5,,r:-5:1&chem=y;s=text_outline;d=666,10.5,l,fff,_,Serialize+%2b+Compress+is+34%25;ds=0;dp=1;py=0;of=51,7%7Cy;s=text_outline;d=666,10.5,l,fff,_,faster+than+Binary+.plist%21;ds=0;dp=1;py=0;of=62,-5" width="350" height="185" alt="Serialize to JSON" />
3693-*23% Faster than Binary* <code><em>.plist</em></code>*&thinsp;!* | *549% Faster than Binary* <code><em>.plist</em></code>*&thinsp;!*
3694-
3695-* Benchmarking was performed on a MacBook Pro with a 2.66GHz Core 2.
3696-* All JSON libraries were compiled with `gcc-4.2 -DNS_BLOCK_ASSERTIONS -O3 -arch x86_64`.
3697-* Timing results are the average of 1,000 iterations of the user + system time reported by [`getrusage`][getrusage].
3698-* The JSON used was [`twitter_public_timeline.json`](https://github.com/samsoffes/json-benchmarks/blob/master/Resources/twitter_public_timeline.json) from [samsoffes / json-benchmarks](https://github.com/samsoffes/json-benchmarks).
3699-* Since the `.plist` format does not support serializing [`NSNull`][NSNull], the `null` values in the original JSON were changed to `"null"`.
3700-* The [experimental](https://github.com/johnezang/JSONKit/tree/experimental) branch contains the `gzip` compression changes.
3701- * JSONKit automagically links to `libz.dylib` on the fly at run time&ndash; no manual linking required.
3702- * Parsing / deserializing will automagically decompress a buffer if it detects a `gzip` signature header.
3703- * You can compress / `gzip` the serialized JSON by passing `JKSerializeOptionCompress` to `-JSONDataWithOptions:error:`.
3704-
3705-[JSON versus PLIST, the Ultimate Showdown](http://www.cocoanetics.com/2011/03/json-versus-plist-the-ultimate-showdown/) benchmarks the common JSON libraries and compares them to Apples `.plist` format.
3706-
3707-***
3708-
3709-JavaScript Object Notation, or [JSON][], is a lightweight, text-based, serialization format for structured data that is used by many web-based services and API's. It is defined by [RFC 4627][].
3710-
3711-JSON provides the following primitive types:
3712-
3713-* `null`
3714-* Boolean `true` and `false`
3715-* Number
3716-* String
3717-* Array
3718-* Object (a.k.a. Associative Arrays, Key / Value Hash Tables, Maps, Dictionaries, etc.)
3719-
3720-These primitive types are mapped to the following Objective-C Foundation classes:
3721-
3722-JSON | Objective-C
3723--------------------|-------------
3724-`null` | [`NSNull`][NSNull]
3725-`true` and `false` | [`NSNumber`][NSNumber]
3726-Number | [`NSNumber`][NSNumber]
3727-String | [`NSString`][NSString]
3728-Array | [`NSArray`][NSArray]
3729-Object | [`NSDictionary`][NSDictionary]
3730-
3731-JSONKit uses Core Foundation internally, and it is assumed that Core Foundation &equiv; Foundation for every equivalent base type, i.e. [`CFString`][CFString] &equiv; [`NSString`][NSString].
3732-
3733-The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC 2119][].
3734-
3735-### JSON To Objective-C Primitive Mapping Details
3736-
3737-* The [JSON specification][RFC 4627] is somewhat ambiguous about the details and requirements when it comes to Unicode, and it does not specify how Unicode issues and errors should be handled. Most of the ambiguity stems from the interpretation and scope [RFC 4627][] Section 3, Encoding: `JSON text SHALL be encoded in Unicode.` It is the authors opinion and interpretation that the language of [RFC 4627][] requires that a JSON implementation MUST follow the requirements specified in the [Unicode Standard][], and in particular the [Conformance][Unicode Standard - Conformance] chapter of the [Unicode Standard][], which specifies requirements related to handling, interpreting, and manipulating Unicode text.
3738-
3739- The default behavior for JSONKit is strict [RFC 4627][] conformance. It is the authors opinion and interpretation that [RFC 4627][] requires JSON to be encoded in Unicode, and therefore JSON that is not legal Unicode as defined by the [Unicode Standard][] is invalid JSON. Therefore, JSONKit will not accept JSON that contains ill-formed Unicode. The default, strict behavior implies that the `JKParseOptionLooseUnicode` option is not enabled.
3740-
3741- When the `JKParseOptionLooseUnicode` option is enabled, JSONKit follows the specifications and recommendations given in [The Unicode 6.0 standard, Chapter 3 - Conformance][Unicode Standard - Conformance], section 3.9 *Unicode Encoding Forms*. As a general rule of thumb, the Unicode code point `U+FFFD` is substituted for any ill-formed Unicode encountered. JSONKit attempts to follow the recommended *Best Practice for Using U+FFFD*: ***Replace each maximal subpart of an ill-formed subsequence by a single U+FFFD.***
3742-
3743- The following Unicode code points are treated as ill-formed Unicode, and if `JKParseOptionLooseUnicode` is enabled, cause `U+FFFD` to be substituted in their place:
3744-
3745- `U+0000`.<br>
3746- `U+D800` thru `U+DFFF`, inclusive.<br>
3747- `U+FDD0` thru `U+FDEF`, inclusive.<br>
3748- <code>U+<i>n</i>FFFE</code> and <code>U+<i>n</i>FFFF</code>, where *n* is from `0x0` to `0x10`
3749-
3750- The code points `U+FDD0` thru `U+FDEF`, <code>U+<i>n</i>FFFE</code>, and <code>U+<i>n</i>FFFF</code> (where *n* is from `0x0` to `0x10`), are defined as ***Noncharacters*** by the Unicode standard and "should never be interchanged".
3751-
3752- An exception is made for the code point `U+0000`, which is legal Unicode. The reason for this is that this particular code point is used by C string handling code to specify the end of the string, and any such string handling code will incorrectly stop processing a string at the point where `U+0000` occurs. Although reasonable people may have different opinions on this point, it is the authors considered opinion that the risks of permitting JSON Strings that contain `U+0000` outweigh the benefits. One of the risks in allowing `U+0000` to appear unaltered in a string is that it has the potential to create security problems by subtly altering the semantics of the string which can then be exploited by a malicious attacker. This is similar to the issue of [arbitrarily deleting characters from Unicode text][Unicode_UTR36_Deleting].
3753-
3754- [RFC 4627][] allows for these limitations under section 4, Parsers: `An implementation may set limits on the length and character contents of strings.` While the [Unicode Standard][] permits the mutation of the original JSON (i.e., substituting `U+FFFD` for ill-formed Unicode), [RFC 4627][] is silent on this issue. It is the authors opinion and interpretation that [RFC 4627][], section 3 &ndash; *Encoding*, `JSON text SHALL be encoded in Unicode.` implies that such mutations are not only permitted but MUST be expected by any strictly conforming [RFC 4627][] JSON implementation. The author feels obligated to note that this opinion and interpretation may not be shared by others and, in fact, may be a minority opinion and interpretation. You should be aware that any mutation of the original JSON may subtly alter its semantics and, as a result, may have security related implications for anything that consumes the final result.
3755-
3756- It is important to note that JSONKit will not delete characters from the JSON being parsed as this is a [requirement specified by the Unicode Standard][Unicode_UTR36_Deleting]. Additional information can be found in the [Unicode Security FAQ][Unicode_Security_FAQ] and [Unicode Technical Report #36 - Unicode Security Consideration][Unicode_UTR36], in particular the section on [non-visual security][Unicode_UTR36_NonVisualSecurity].
3757-
3758-* The [JSON specification][RFC 4627] does not specify the details or requirements for JSON String values, other than such strings must consist of Unicode code points, nor does it specify how errors should be handled. While JSONKit makes an effort (subject to the reasonable caveats above regarding Unicode) to preserve the parsed JSON String exactly, it can not guarantee that [`NSString`][NSString] will preserve the exact Unicode semantics of the original JSON String.
3759-
3760- JSONKit does not perform any form of Unicode Normalization on the parsed JSON Strings, but can not make any guarantees that the [`NSString`][NSString] class will not perform Unicode Normalization on the parsed JSON String used to instantiate the [`NSString`][NSString] object. The [`NSString`][NSString] class may place additional restrictions or otherwise transform the JSON String in such a way so that the JSON String is not bijective with the instantiated [`NSString`][NSString] object. In other words, JSONKit can not guarantee that when you round trip a JSON String to a [`NSString`][NSString] and then back to a JSON String that the two JSON Strings will be exactly the same, even though in practice they are. For clarity, "exactly" in this case means bit for bit identical. JSONKit can not even guarantee that the two JSON Strings will be [Unicode equivalent][Unicode_equivalence], even though in practice they will be and would be the most likely cause for the two round tripped JSON Strings to no longer be bit for bit identical.
3761-
3762-* JSONKit maps `true` and `false` to the [`CFBoolean`][CFBoolean] values [`kCFBooleanTrue`][kCFBooleanTrue] and [`kCFBooleanFalse`][kCFBooleanFalse], respectively. Conceptually, [`CFBoolean`][CFBoolean] values can be thought of, and treated as, [`NSNumber`][NSNumber] class objects. The benefit to using [`CFBoolean`][CFBoolean] is that `true` and `false` JSON values can be round trip deserialized and serialized without conversion or promotion to a [`NSNumber`][NSNumber] with a value of `0` or `1`.
3763-
3764-* The [JSON specification][RFC 4627] does not specify the details or requirements for JSON Number values, nor does it specify how errors due to conversion should be handled. In general, JSONKit will not accept JSON that contains JSON Number values that it can not convert with out error or loss of precision.
3765-
3766- For non-floating-point numbers (i.e., JSON Number values that do not include a `.` or `e|E`), JSONKit uses a 64-bit C primitive type internally, regardless of whether the target architecture is 32-bit or 64-bit. For unsigned values (i.e., those that do not begin with a `-`), this allows for values up to <code>2<sup>64</sup>-1</code> and up to <code>-2<sup>63</sup></code> for negative values. As a special case, the JSON Number `-0` is treated as a floating-point number since the underlying floating-point primitive type is capable of representing a negative zero, whereas the underlying twos-complement non-floating-point primitive type can not. JSON that contains Number values that exceed these limits will fail to parse and optionally return a [`NSError`][NSError] object. The functions [`strtoll()`][strtoll] and [`strtoull()`][strtoull] are used to perform the conversions.
3767-
3768- The C `double` primitive type, or [IEEE 754 Double 64-bit floating-point][Double Precision], is used to represent floating-point JSON Number values. JSON that contains floating-point Number values that can not be represented as a `double` (i.e., due to over or underflow) will fail to parse and optionally return a [`NSError`][NSError] object. The function [`strtod()`][strtod] is used to perform the conversion. Note that the JSON standard does not allow for infinities or `NaN` (Not a Number). The conversion and manipulation of [floating-point values is non-trivial](http://www.validlab.com/goldberg/paper.pdf). Unfortunately, [RFC 4627][] is silent on how such details should be handled. You should not depend on or expect that when a floating-point value is round tripped that it will have the same textual representation or even compare equal. This is true even when JSONKit is used as both the parser and creator of the JSON, let alone when transferring JSON between different systems and implementations.
3769-
3770-* For JSON Objects (or [`NSDictionary`][NSDictionary] in JSONKit nomenclature), [RFC 4627][] says `The names within an object SHOULD be unique` (note: `name` is a `key` in JSONKit nomenclature). At this time the JSONKit behavior is `undefined` for JSON that contains names within an object that are not unique. However, JSONKit currently tries to follow a "the last key / value pair parsed is the one chosen" policy. This behavior is not finalized and should not be depended on.
3771-
3772- The previously covered limitations regarding JSON Strings have important consequences for JSON Objects since JSON Strings are used as the `key`. The [JSON specification][RFC 4627] does not specify the details or requirements for JSON Strings used as `keys` in JSON Objects, specifically what it means for two `keys` to compare equal. Unfortunately, because [RFC 4627][] states `JSON text SHALL be encoded in Unicode.`, this means that one must use the [Unicode Standard][] to interpret the JSON, and the [Unicode Standard][] allows for strings that are encoded with different Unicode Code Points to "compare equal". JSONKit uses [`NSString`][NSString] exclusively to manage the parsed JSON Strings. Because [`NSString`][NSString] uses [Unicode][Unicode Standard] as its basis, there exists the possibility that [`NSString`][NSString] may subtly and silently convert the Unicode Code Points contained in the original JSON String in to a [Unicode equivalent][Unicode_equivalence] string. Due to this, the JSONKit behavior for JSON Strings used as `keys` in JSON Objects that may be [Unicode equivalent][Unicode_equivalence] but not binary equivalent is `undefined`.
3773-
3774- **See also:**<br />
3775- &nbsp;&nbsp;&nbsp;&nbsp;[W3C - Requirements for String Identity Matching and String Indexing](http://www.w3.org/TR/charreq/#sec2)
3776-
3777-### Objective-C To JSON Primitive Mapping Details
3778-
3779-* When serializing, the top level container, and all of its children, are required to be *strictly* [invariant][wiki_invariant] during enumeration. This property is used to make certain optimizations, such as if a particular object has already been serialized, the result of the previous serialized `UTF8` string can be reused (i.e., the `UTF8` string of the previous serialization can simply be copied instead of performing all the serialization work again). While this is probably only of interest to those who are doing extraordinarily unusual things with the run-time or custom classes inheriting from the classes that JSONKit will serialize (i.e, a custom object whose value mutates each time it receives a message requesting its value for serialization), it also covers the case where any of the objects to be serialized are mutated during enumeration (i.e., mutated by another thread). The number of times JSONKit will request an objects value is non-deterministic, from a minimum of once up to the number of times it appears in the serialized JSON&ndash; therefore an object MUST NOT depend on receiving a message requesting its value each time it appears in the serialized output. The behavior is `undefined` if these requirements are violated.
3780-
3781-* The objects to be serialized MUST be acyclic. If the objects to be serialized contain circular references the behavior is `undefined`. For example,
3782-
3783- ```objective-c
3784- [arrayOne addObject:arrayTwo];
3785- [arrayTwo addObject:arrayOne];
3786- id json = [arrayOne JSONString];
3787- ```
3788-
3789- &hellip; will result in `undefined` behavior.
3790-
3791-* The contents of [`NSString`][NSString] objects are encoded as `UTF8` and added to the serialized JSON. JSONKit assumes that [`NSString`][NSString] produces well-formed `UTF8` Unicode and does no additional validation of the conversion. When `JKSerializeOptionEscapeUnicode` is enabled, JSONKit will encode Unicode code points that can be encoded as a single `UTF16` code unit as <code>\u<i>XXXX</i></code>, and will encode Unicode code points that require `UTF16` surrogate pairs as <code>\u<i>high</i>\u<i>low</i></code>. While JSONKit makes every effort to serialize the contents of a [`NSString`][NSString] object exactly, modulo any [RFC 4627][] requirements, the [`NSString`][NSString] class uses the [Unicode Standard][] as its basis for representing strings. You should be aware that the [Unicode Standard][] defines [string equivalence][Unicode_equivalence] in a such a way that two strings that compare equal are not required to be bit for bit identical. Therefore there exists the possibility that [`NSString`][NSString] may mutate a string in such a way that it is [Unicode equivalent][Unicode_equivalence], but not bit for bit identical with the original string.
3792-
3793-* The [`NSDictionary`][NSDictionary] class allows for any object, which can be of any class, to be used as a `key`. JSON, however, only permits Strings to be used as `keys`. Therefore JSONKit will fail with an error if it encounters a [`NSDictionary`][NSDictionary] that contains keys that are not [`NSString`][NSString] objects during serialization. More specifically, the keys must return `YES` when sent [`-isKindOfClass:[NSString class]`][-isKindOfClass:].
3794-
3795-* JSONKit will fail with an error if it encounters an object that is not a [`NSNull`][NSNull], [`NSNumber`][NSNumber], [`NSString`][NSString], [`NSArray`][NSArray], or [`NSDictionary`][NSDictionary] class object during serialization. More specifically, JSONKit will fail with an error if it encounters an object where [`-isKindOfClass:`][-isKindOfClass:] returns `NO` for all of the previously mentioned classes.
3796-
3797-* JSON does not allow for Numbers that are <code>&plusmn;Infinity</code> or <code>&plusmn;NaN</code>. Therefore JSONKit will fail with an error if it encounters a [`NSNumber`][NSNumber] that contains such a value during serialization.
3798-
3799-* Objects created with [`[NSNumber numberWithBool:YES]`][NSNumber_numberWithBool] and [`[NSNumber numberWithBool:NO]`][NSNumber_numberWithBool] will be mapped to the JSON values of `true` and `false`, respectively. More specifically, an object must have pointer equality with [`kCFBooleanTrue`][kCFBooleanTrue] or [`kCFBooleanFalse`][kCFBooleanFalse] (i.e., `if((id)object == (id)kCFBooleanTrue)`) in order to be mapped to the JSON values `true` and `false`.
3800-
3801-* [`NSNumber`][NSNumber] objects that are not booleans (as defined above) are sent [`-objCType`][-objCType] to determine what type of C primitive type they represent. Those that respond with a type from the set `cislq` are treated as `long long`, those that respond with a type from the set `CISLQB` are treated as `unsigned long long`, and those that respond with a type from the set `fd` are treated as `double`. [`NSNumber`][NSNumber] objects that respond with a type not in the set of types mentioned will cause JSONKit to fail with an error.
3802-
3803- More specifically, [`CFNumberGetValue(object, kCFNumberLongLongType, &longLong)`][CFNumberGetValue] is used to retrieve the value of both the signed and unsigned integer values, and the type reported by [`-objCType`][-objCType] is used to determine whether the result is signed or unsigned. For floating-point values, [`CFNumberGetValue`][CFNumberGetValue] is used to retrieve the value using [`kCFNumberDoubleType`][kCFNumberDoubleType] for the type argument.
3804-
3805- Floating-point numbers are converted to their decimal representation using the [`printf`][printf] format conversion specifier `%.17g`. Theoretically this allows up to a `float`, or [IEEE 754 Single 32-bit floating-point][Single Precision], worth of precision to be represented. This means that for practical purposes, `double` values are converted to `float` values with the associated loss of precision. The [RFC 4627][] standard is silent on how floating-point numbers should be dealt with and the author has found that real world JSON implementations vary wildly in how they handle this issue. Furthermore, the `%g` format conversion specifier may convert floating-point values that can be exactly represented as an integer to a textual representation that does not include a `.` or `e`&ndash; essentially silently promoting a floating-point value to an integer value (i.e, `5.0` becomes `5`). Because of these and many other issues surrounding the conversion and manipulation of floating-point values, you should not expect or depend on floating point values to maintain their full precision, or when round tripped, to compare equal.
3806-
3807-
3808-### Reporting Bugs
3809-
3810-Please use the [github.com JSONKit Issue Tracker](https://github.com/johnezang/JSONKit/issues) to report bugs.
3811-
3812-The author requests that you do not file a bug report with JSONKit regarding problems reported by the `clang` static analyzer unless you first manually verify that it is an actual, bona-fide problem with JSONKit and, if appropriate, is not "legal" C code as defined by the C99 language specification. If the `clang` static analyzer is reporting a problem with JSONKit that is not an actual, bona-fide problem and is perfectly legal code as defined by the C99 language specification, then the appropriate place to file a bug report or complaint is with the developers of the `clang` static analyzer.
3813-
3814-### Important Details
3815-
3816-* JSONKit is not designed to be used with the Mac OS X Garbage Collection. The behavior of JSONKit when compiled with `-fobjc-gc` is `undefined`. It is extremely unlikely that Mac OS X Garbage Collection will ever be supported.
3817-
3818-* JSONKit is not designed to be used with [Objective-C Automatic Reference Counting (ARC)][ARC]. The behavior of JSONKit when compiled with `-fobjc-arc` is `undefined`. The behavior of JSONKit compiled without [ARC][] mixed with code that has been compiled with [ARC][] is normatively `undefined` since at this time no analysis has been done to understand if this configuration is safe to use. At this time, there are no plans to support [ARC][] in JSONKit. Although tenative, it is extremely unlikely that [ARC][] will ever be supported, for many of the same reasons that Mac OS X Garbage Collection is not supported.
3819-
3820-* The JSON to be parsed by JSONKit MUST be encoded as Unicode. In the unlikely event you end up with JSON that is not encoded as Unicode, you must first convert the JSON to Unicode, preferably as `UTF8`. One way to accomplish this is with the [`NSString`][NSString] methods [`-initWithBytes:length:encoding:`][NSString_initWithBytes] and [`-initWithData:encoding:`][NSString_initWithData].
3821-
3822-* Internally, the low level parsing engine uses `UTF8` exclusively. The `JSONDecoder` method `-objectWithData:` takes a [`NSData`][NSData] object as its argument and it is assumed that the raw bytes contained in the [`NSData`][NSData] is `UTF8` encoded, otherwise the behavior is `undefined`.
3823-
3824-* It is not safe to use the same instantiated `JSONDecoder` object from multiple threads at the same time. If you wish to share a `JSONDecoder` between threads, you are responsible for adding mutex barriers to ensure that only one thread is decoding JSON using the shared `JSONDecoder` object at a time.
3825-
3826-### Tips for speed
3827-
3828-* Enable the `NS_BLOCK_ASSERTIONS` pre-processor flag. JSONKit makes heavy use of [`NSCParameterAssert()`][NSCParameterAssert] internally to ensure that various arguments, variables, and other state contains only legal and expected values. If an assertion check fails it causes a run time exception that will normally cause a program to terminate. These checks and assertions come with a price: they take time to execute and do not contribute to the work being performed. It is perfectly safe to enable `NS_BLOCK_ASSERTIONS` as JSONKit always performs checks that are required for correct operation. The checks performed with [`NSCParameterAssert()`][NSCParameterAssert] are completely optional and are meant to be used in "debug" builds where extra integrity checks are usually desired. While your mileage may vary, the author has found that adding `-DNS_BLOCK_ASSERTIONS` to an `-O2` optimization setting can generally result in an approximate <span style="white-space: nowrap;">7-12%</span> increase in performance.
3829-
3830-* Since the very low level parsing engine works exclusively with `UTF8` byte streams, anything that is not already encoded as `UTF8` must first be converted to `UTF8`. While JSONKit provides additions to the [`NSString`][NSString] class which allows you to conveniently convert JSON contained in a [`NSString`][NSString], this convenience does come with a price. JSONKit must allocate an autoreleased [`NSMutableData`][NSMutableData] large enough to hold the strings `UTF8` conversion and then convert the string to `UTF8` before it can begin parsing. This takes both memory and time. Once the parsing has finished, JSONKit sets the autoreleased [`NSMutableData`][NSMutableData] length to `0`, which allows the [`NSMutableData`][NSMutableData] to release the memory. This helps to minimize the amount of memory that is in use but unavailable until the autorelease pool pops. Therefore, if speed and memory usage are a priority, you should avoid using the [`NSString`][NSString] convenience methods if possible.
3831-
3832-* If you are receiving JSON data from a web server, and you are able to determine that the raw bytes returned by the web server is JSON encoded as `UTF8`, you should use the `JSONDecoder` method `-objectWithUTF8String:length:` which immediately begins parsing the pointers bytes. In practice, every JSONKit method that converts JSON to an Objective-C object eventually calls this method to perform the conversion.
3833-
3834-* If you are using one of the various ways provided by the `NSURL` family of classes to receive JSON results from a web server, which typically return the results in the form of a [`NSData`][NSData] object, and you are able to determine that the raw bytes contained in the [`NSData`][NSData] are encoded as `UTF8`, then you should use either the `JSONDecoder` method `objectWithData:` or the [`NSData`][NSData] method `-objectFromJSONData`. If are going to be converting a lot of JSON, the better choice is to instantiate a `JSONDecoder` object once and use the same instantiated object to perform all your conversions. This has two benefits:
3835- 1. The [`NSData`][NSData] method `-objectFromJSONData` creates an autoreleased `JSONDecoder` object to perform the one time conversion. By instantiating a `JSONDecoder` object once and using the `objectWithData:` method repeatedly, you can avoid this overhead.
3836- 2. The instantiated object cache from the previous JSON conversion is reused. This can result in both better performance and a reduction in memory usage if the JSON your are converting is very similar. A typical example might be if you are converting JSON at periodic intervals that consists of real time status updates.
3837-
3838-* On average, the <code>JSONData&hellip;</code> methods are nearly four times faster than the <code>JSONString&hellip;</code> methods when serializing a [`NSDictionary`][NSDictionary] or [`NSArray`][NSArray] to JSON. The difference in speed is due entirely to the instantiation overhead of [`NSString`][NSString].
3839-
3840-* If at all possible, use [`NSData`][NSData] instead of [`NSString`][NSString] methods when processing JSON. This avoids the sometimes significant conversion overhead that [`NSString`][NSString] performs in order to provide an object oriented interface for its contents. For many uses, using [`NSString`][NSString] is not needed and results in wasted effort&ndash; for example, using JSONKit to serialize a [`NSDictionary`][NSDictionary] or [`NSArray`][NSArray] to a [`NSString`][NSString]. This [`NSString`][NSString] is then passed to a method that sends the JSON to a web server, and this invariably requires converting the [`NSString`][NSString] to [`NSData`][NSData] before it can be sent. In this case, serializing the collection object directly to [`NSData`][NSData] would avoid the unnecessary conversions to and from a [`NSString`][NSString] object.
3841-
3842-### Parsing Interface
3843-
3844-#### JSONDecoder Interface
3845-
3846-The <code>objectWith&hellip;</code> methods return immutable collection objects and their respective <code>mutableObjectWith&hellip;</code> methods return mutable collection objects.
3847-
3848-**Note:** The bytes contained in a [`NSData`][NSData] object ***MUST*** be `UTF8` encoded.
3849-
3850-**Important:** Methods will raise [`NSInvalidArgumentException`][NSInvalidArgumentException] if `parseOptionFlags` is not valid.
3851-**Important:** `objectWithUTF8String:` and `mutableObjectWithUTF8String:` will raise [`NSInvalidArgumentException`][NSInvalidArgumentException] if `string` is `NULL`.
3852-**Important:** `objectWithData:` and `mutableObjectWithData:` will raise [`NSInvalidArgumentException`][NSInvalidArgumentException] if `jsonData` is `NULL`.
3853-
3854-```objective-c
3855-+ (id)decoder;
3856-+ (id)decoderWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
3857-- (id)initWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
3858-
3859-- (void)clearCache;
3860-
3861-- (id)objectWithUTF8String:(const unsigned char *)string length:(size_t)length;
3862-- (id)objectWithUTF8String:(const unsigned char *)string length:(size_t)length error:(NSError **)error;
3863-- (id)mutableObjectWithUTF8String:(const unsigned char *)string length:(size_t)length;
3864-- (id)mutableObjectWithUTF8String:(const unsigned char *)string length:(size_t)length error:(NSError **)error;
3865-
3866-- (id)objectWithData:(NSData *)jsonData;
3867-- (id)objectWithData:(NSData *)jsonData error:(NSError **)error;
3868-- (id)mutableObjectWithData:(NSData *)jsonData;
3869-- (id)mutableObjectWithData:(NSData *)jsonData error:(NSError **)error;
3870-```
3871-
3872-#### NSString Interface
3873-
3874-```objective-c
3875-- (id)objectFromJSONString;
3876-- (id)objectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
3877-- (id)objectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error;
3878-- (id)mutableObjectFromJSONString;
3879-- (id)mutableObjectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
3880-- (id)mutableObjectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error;
3881-```
3882-
3883-#### NSData Interface
3884-
3885-```objective-c
3886-- (id)objectFromJSONData;
3887-- (id)objectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
3888-- (id)objectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error;
3889-- (id)mutableObjectFromJSONData;
3890-- (id)mutableObjectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
3891-- (id)mutableObjectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error;
3892-```
3893-
3894-#### JKParseOptionFlags
3895-
3896-<table>
3897- <tr><th>Parsing Option</th><th>Description</th></tr>
3898- <tr><td valign="top"><code>JKParseOptionNone</code></td><td>This is the default if no other other parse option flags are specified, and the option used when a convenience method does not provide an argument for explicitly specifying the parse options to use. Synonymous with <code>JKParseOptionStrict</code>.</td></tr>
3899- <tr><td valign="top"><code>JKParseOptionStrict</code></td><td>The JSON will be parsed in strict accordance with the <a href="http://tools.ietf.org/html/rfc4627">RFC 4627</a> specification.</td></tr>
3900- <tr><td valign="top"><code>JKParseOptionComments</code></td><td>Allow C style <code>//</code> and <code>/* &hellip; */</code> comments in JSON. This is a fairly common extension to JSON, but JSON that contains C style comments is not strictly conforming JSON.</td></tr>
3901- <tr><td valign="top"><code>JKParseOptionUnicodeNewlines</code></td><td>Allow Unicode recommended <code>(?:\r\n|[\n\v\f\r\x85\p{Zl}\p{Zp}])</code> newlines in JSON. The <a href="http://tools.ietf.org/html/rfc4627">JSON specification</a> only allows the newline characters <code>\r</code> and <code>\n</code>, but this option allows JSON that contains the <a href="http://en.wikipedia.org/wiki/Newline#Unicode">Unicode recommended newline characters</a> to be parsed. JSON that contains these additional newline characters is not strictly conforming JSON.</td></tr>
3902- <tr><td valign="top"><code>JKParseOptionLooseUnicode</code></td><td>Normally the decoder will stop with an error at any malformed Unicode. This option allows JSON with malformed Unicode to be parsed without reporting an error. Any malformed Unicode is replaced with <code>\uFFFD</code>, or <code>REPLACEMENT CHARACTER</code>, as specified in <a href="http://www.unicode.org/versions/Unicode6.0.0/ch03.pdf">The Unicode 6.0 standard, Chapter 3</a>, section 3.9 <em>Unicode Encoding Forms</em>.</td></tr>
3903- <tr><td valign="top"><code>JKParseOptionPermitTextAfterValidJSON</code></td><td>Normally, <code>non-white-space</code> that follows the JSON is interpreted as a parsing failure. This option allows for any trailing <code>non-white-space</code> to be ignored and not cause a parsing error.</td></tr>
3904-</table>
3905-
3906-### Serializing Interface
3907-
3908-The serializing interface includes [`NSString`][NSString] convenience methods for those that need to serialize a single [`NSString`][NSString]. For those that need this functionality, the [`NSString`][NSString] additions are much more convenient than having to wrap a single [`NSString`][NSString] in a [`NSArray`][NSArray], which then requires stripping the unneeded `[`&hellip;`]` characters from the serialized JSON result. When serializing a single [`NSString`][NSString], you can control whether or not the serialized JSON result is surrounded by quotation marks using the `includeQuotes:` argument:
3909-
3910-Example | Result | Argument
3911---------------|-------------------|--------------------
3912-`a "test"...` | `"a \"test\"..."` | `includeQuotes:YES`
3913-`a "test"...` | `a \"test\"...` | `includeQuotes:NO`
3914-
3915-**Note:** The [`NSString`][NSString] methods that do not include a `includeQuotes:` argument behave as if invoked with `includeQuotes:YES`.
3916-**Note:** The bytes contained in the returned [`NSData`][NSData] object are `UTF8` encoded.
3917-
3918-#### NSArray and NSDictionary Interface
3919-
3920-```objective-c
3921-- (NSData *)JSONData;
3922-- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error;
3923-- (NSString *)JSONString;
3924-- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error;
3925-```
3926-
3927-
3928-#### NSString Interface
3929-
3930-```objective-c
3931-- (NSData *)JSONData;
3932-- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions includeQuotes:(BOOL)includeQuotes error:(NSError **)error;
3933-- (NSString *)JSONString;
3934-- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions includeQuotes:(BOOL)includeQuotes error:(NSError **)error;
3935-```
3936-
3937-#### JKSerializeOptionFlags
3938-
3939-<table>
3940- <tr><th>Serializing Option</th><th>Description</th></tr>
3941- <tr><td valign="top"><code>JKSerializeOptionNone</code></td><td>This is the default if no other other serialize option flags are specified, and the option used when a convenience method does not provide an argument for explicitly specifying the serialize options to use.</td></tr>
3942- <tr><td valign="top"><code>JKSerializeOptionPretty</code></td><td>Normally the serialized JSON does not include any unnecessary <code>white-space</code>. While this form is the most compact, the lack of any <code>white-space</code> means that it's something only another JSON parser could love. Enabling this option causes JSONKit to add additional <code>white-space</code> that makes it easier for people to read. Other than the extra <code>white-space</code>, the serialized JSON is identical to the JSON that would have been produced had this option not been enabled.</td></tr>
3943- <tr><td valign="top"><code>JKSerializeOptionEscapeUnicode</code></td><td>When JSONKit encounters Unicode characters in <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/index.html"><code>NSString</code></a> objects, the default behavior is to encode those Unicode characters as <code>UTF8</code>. This option causes JSONKit to encode those characters as <code>\u<i>XXXX</i></code>. For example,<br/><code>["w&isin;L&#10234;y(&#8739;y&#8739;&le;&#8739;w&#8739;)"]</code><br/>becomes:<br/><code>["w\u2208L\u27fa\u2203y(\u2223y\u2223\u2264\u2223w\u2223)"]</code></td></tr>
3944- <tr><td valign="top"><code>JKSerializeOptionEscapeForwardSlashes</code></td><td>According to the <a href="http://tools.ietf.org/html/rfc4627">JSON specification</a>, the <code>/</code> (<code>U+002F</code>) character may be backslash escaped (i.e., <code>\/</code>), but it is not required. The default behavior of JSONKit is to <b><i>not</i></b> backslash escape the <code>/</code> character. Unfortunately, it was found some real world implementations of the <a href="http://weblogs.asp.net/bleroy/archive/2008/01/18/dates-and-json.aspx">ASP.NET Date Format</a> require the date to be <i>strictly</i> encoded as <code>\/Date(...)\/</code>, and the only way to achieve this is through the use of <code>JKSerializeOptionEscapeForwardSlashes</code>. See <a href="https://github.com/johnezang/JSONKit/issues/21">github issue #21</a> for more information.</td></tr>
3945-</table>
3946-
3947-[JSON]: http://www.json.org/
3948-[RFC 4627]: http://tools.ietf.org/html/rfc4627
3949-[RFC 2119]: http://tools.ietf.org/html/rfc2119
3950-[Single Precision]: http://en.wikipedia.org/wiki/Single_precision_floating-point_format
3951-[Double Precision]: http://en.wikipedia.org/wiki/Double_precision_floating-point_format
3952-[wiki_invariant]: http://en.wikipedia.org/wiki/Invariant_(computer_science)
3953-[ARC]: http://clang.llvm.org/docs/AutomaticReferenceCounting.html
3954-[CFBoolean]: http://developer.apple.com/mac/library/documentation/CoreFoundation/Reference/CFBooleanRef/index.html
3955-[kCFBooleanTrue]: http://developer.apple.com/mac/library/documentation/CoreFoundation/Reference/CFBooleanRef/Reference/reference.html#//apple_ref/doc/c_ref/kCFBooleanTrue
3956-[kCFBooleanFalse]: http://developer.apple.com/mac/library/documentation/CoreFoundation/Reference/CFBooleanRef/Reference/reference.html#//apple_ref/doc/c_ref/kCFBooleanFalse
3957-[kCFNumberDoubleType]: http://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFNumberRef/Reference/reference.html#//apple_ref/doc/c_ref/kCFNumberDoubleType
3958-[CFNumberGetValue]: http://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFNumberRef/Reference/reference.html#//apple_ref/c/func/CFNumberGetValue
3959-[Unicode Standard]: http://www.unicode.org/versions/Unicode6.0.0/
3960-[Unicode Standard - Conformance]: http://www.unicode.org/versions/Unicode6.0.0/ch03.pdf
3961-[Unicode_equivalence]: http://en.wikipedia.org/wiki/Unicode_equivalence
3962-[UnicodeNewline]: http://en.wikipedia.org/wiki/Newline#Unicode
3963-[Unicode_UTR36]: http://www.unicode.org/reports/tr36/
3964-[Unicode_UTR36_NonVisualSecurity]: http://www.unicode.org/reports/tr36/#Canonical_Represenation
3965-[Unicode_UTR36_Deleting]: http://www.unicode.org/reports/tr36/#Deletion_of_Noncharacters
3966-[Unicode_Security_FAQ]: http://www.unicode.org/faq/security.html
3967-[NSNull]: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSNull_Class/index.html
3968-[NSNumber]: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/index.html
3969-[NSNumber_numberWithBool]: http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/Reference/Reference.html#//apple_ref/occ/clm/NSNumber/numberWithBool:
3970-[NSString]: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/index.html
3971-[NSString_initWithBytes]: http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/initWithBytes:length:encoding:
3972-[NSString_initWithData]: http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/initWithData:encoding:
3973-[NSString_UTF8String]: http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/UTF8String
3974-[NSArray]: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/index.html
3975-[NSDictionary]: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/index.html
3976-[NSError]: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSError_Class/index.html
3977-[NSData]: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSData_Class/index.html
3978-[NSMutableData]: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSMutableData_Class/index.html
3979-[NSInvalidArgumentException]: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Constants/Reference/reference.html#//apple_ref/doc/c_ref/NSInvalidArgumentException
3980-[CFString]: http://developer.apple.com/library/mac/#documentation/CoreFoundation/Reference/CFStringRef/Reference/reference.html
3981-[NSCParameterAssert]: http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html#//apple_ref/c/macro/NSCParameterAssert
3982-[-mutableCopy]: http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/Reference/Reference.html%23//apple_ref/occ/instm/NSObject/mutableCopy
3983-[-isKindOfClass:]: http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Protocols/NSObject_Protocol/Reference/NSObject.html%23//apple_ref/occ/intfm/NSObject/isKindOfClass:
3984-[-objCType]: http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/Reference/Reference.html#//apple_ref/occ/instm/NSNumber/objCType
3985-[strtoll]: http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/strtoll.3.html
3986-[strtod]: http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/strtod.3.html
3987-[strtoull]: http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/strtoull.3.html
3988-[getrusage]: http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man2/getrusage.2.html
3989-[printf]: http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/printf.3.html
3990
3991=== removed directory 'Dependencies/Reachability'
3992=== removed file 'Dependencies/Reachability/Reachability.h'
3993--- Dependencies/Reachability/Reachability.h 2011-11-01 01:43:45 +0000
3994+++ Dependencies/Reachability/Reachability.h 1970-01-01 00:00:00 +0000
3995@@ -1,88 +0,0 @@
3996-/*
3997-
3998- File: Reachability.h
3999- Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs.
4000-
4001- Version: 2.0
4002-
4003- Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
4004- ("Apple") in consideration of your agreement to the following terms, and your
4005- use, installation, modification or redistribution of this Apple software
4006- constitutes acceptance of these terms. If you do not agree with these terms,
4007- please do not use, install, modify or redistribute this Apple software.
4008-
4009- In consideration of your agreement to abide by the following terms, and subject
4010- to these terms, Apple grants you a personal, non-exclusive license, under
4011- Apple's copyrights in this original Apple software (the "Apple Software"), to
4012- use, reproduce, modify and redistribute the Apple Software, with or without
4013- modifications, in source and/or binary forms; provided that if you redistribute
4014- the Apple Software in its entirety and without modifications, you must retain
4015- this notice and the following text and disclaimers in all such redistributions
4016- of the Apple Software.
4017- Neither the name, trademarks, service marks or logos of Apple Inc. may be used
4018- to endorse or promote products derived from the Apple Software without specific
4019- prior written permission from Apple. Except as expressly stated in this notice,
4020- no other rights or licenses, express or implied, are granted by Apple herein,
4021- including but not limited to any patent rights that may be infringed by your
4022- derivative works or by other works in which the Apple Software may be
4023- incorporated.
4024-
4025- The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
4026- WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
4027- WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
4028- PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
4029- COMBINATION WITH YOUR PRODUCTS.
4030-
4031- IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
4032- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
4033- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4034- ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR
4035- DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
4036- CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
4037- APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4038-
4039- Copyright (C) 2009 Apple Inc. All Rights Reserved.
4040-
4041-*/
4042-
4043-
4044-#import <Foundation/Foundation.h>
4045-#import <SystemConfiguration/SystemConfiguration.h>
4046-
4047-typedef enum {
4048- NotReachable = 0,
4049- ReachableViaWiFi,
4050- ReachableViaWWAN
4051-} NetworkStatus;
4052-#define kReachabilityChangedNotification @"kNetworkReachabilityChangedNotification"
4053-
4054-@interface Reachability: NSObject
4055-{
4056- BOOL localWiFiRef;
4057- SCNetworkReachabilityRef reachabilityRef;
4058-}
4059-
4060-//reachabilityWithHostName- Use to check the reachability of a particular host name.
4061-+ (Reachability*) reachabilityWithHostName: (NSString*) hostName;
4062-
4063-//reachabilityWithAddress- Use to check the reachability of a particular IP address.
4064-//+ (Reachability*) reachabilityWithAddress: (const struct sockaddr_in*) hostAddress;
4065-
4066-//reachabilityForInternetConnection- checks whether the default route is available.
4067-// Should be used by applications that do not connect to a particular host
4068-+ (Reachability*) reachabilityForInternetConnection;
4069-
4070-//reachabilityForLocalWiFi- checks whether a local wifi connection is available.
4071-+ (Reachability*) reachabilityForLocalWiFi;
4072-
4073-//Start listening for reachability notifications on the current run loop
4074-- (BOOL) startNotifer;
4075-- (void) stopNotifer;
4076-
4077-- (NetworkStatus) currentReachabilityStatus;
4078-//WWAN may be available, but not active until a connection has been established.
4079-//WiFi may require a connection for VPN on Demand.
4080-- (BOOL) connectionRequired;
4081-@end
4082-
4083-
4084
4085=== removed file 'Dependencies/Reachability/Reachability.m'
4086--- Dependencies/Reachability/Reachability.m 2011-11-01 01:43:45 +0000
4087+++ Dependencies/Reachability/Reachability.m 1970-01-01 00:00:00 +0000
4088@@ -1,274 +0,0 @@
4089-/*
4090-
4091- File: Reachability.m
4092- Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs.
4093-
4094- Version: 2.0
4095-
4096- Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
4097- ("Apple") in consideration of your agreement to the following terms, and your
4098- use, installation, modification or redistribution of this Apple software
4099- constitutes acceptance of these terms. If you do not agree with these terms,
4100- please do not use, install, modify or redistribute this Apple software.
4101-
4102- In consideration of your agreement to abide by the following terms, and subject
4103- to these terms, Apple grants you a personal, non-exclusive license, under
4104- Apple's copyrights in this original Apple software (the "Apple Software"), to
4105- use, reproduce, modify and redistribute the Apple Software, with or without
4106- modifications, in source and/or binary forms; provided that if you redistribute
4107- the Apple Software in its entirety and without modifications, you must retain
4108- this notice and the following text and disclaimers in all such redistributions
4109- of the Apple Software.
4110- Neither the name, trademarks, service marks or logos of Apple Inc. may be used
4111- to endorse or promote products derived from the Apple Software without specific
4112- prior written permission from Apple. Except as expressly stated in this notice,
4113- no other rights or licenses, express or implied, are granted by Apple herein,
4114- including but not limited to any patent rights that may be infringed by your
4115- derivative works or by other works in which the Apple Software may be
4116- incorporated.
4117-
4118- The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
4119- WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
4120- WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
4121- PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
4122- COMBINATION WITH YOUR PRODUCTS.
4123-
4124- IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
4125- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
4126- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4127- ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR
4128- DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
4129- CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
4130- APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4131-
4132- Copyright (C) 2009 Apple Inc. All Rights Reserved.
4133-
4134-*/
4135-
4136-#import <sys/socket.h>
4137-#import <netinet/in.h>
4138-#import <netinet6/in6.h>
4139-#import <arpa/inet.h>
4140-#import <ifaddrs.h>
4141-#import <netdb.h>
4142-
4143-#import <CoreFoundation/CoreFoundation.h>
4144-
4145-#import "Reachability.h"
4146-
4147-#define kShouldPrintReachabilityFlags 0
4148-
4149-static void PrintReachabilityFlags(SCNetworkReachabilityFlags flags, const char* comment)
4150-{
4151-#if kShouldPrintReachabilityFlags
4152-
4153- NSLog(@"Reachability Flag Status: %c%c %c%c%c%c%c%c%c %s\n",
4154- (flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-',
4155- (flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-',
4156-
4157- (flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-',
4158- (flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-',
4159- (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) ? 'C' : '-',
4160- (flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-',
4161- (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-',
4162- (flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-',
4163- (flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-',
4164- comment
4165- );
4166-#endif
4167-}
4168-
4169-
4170-@implementation Reachability
4171-static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info)
4172-{
4173- #pragma unused (target, flags)
4174- NSCAssert(info != NULL, @"info was NULL in ReachabilityCallback");
4175- NSCAssert([(NSObject*) info isKindOfClass: [Reachability class]], @"info was wrong class in ReachabilityCallback");
4176-
4177- //We're on the main RunLoop, so an NSAutoreleasePool is not necessary, but is added defensively
4178- // in case someon uses the Reachablity object in a different thread.
4179- NSAutoreleasePool* myPool = [[NSAutoreleasePool alloc] init];
4180-
4181- Reachability* noteObject = (Reachability*) info;
4182- // Post a notification to notify the client that the network reachability changed.
4183- [[NSNotificationCenter defaultCenter] postNotificationName: kReachabilityChangedNotification object: noteObject];
4184-
4185- [myPool release];
4186-}
4187-
4188-- (BOOL) startNotifer
4189-{
4190- BOOL retVal = NO;
4191- SCNetworkReachabilityContext context = {0, self, NULL, NULL, NULL};
4192- if(SCNetworkReachabilitySetCallback(reachabilityRef, ReachabilityCallback, &context))
4193- {
4194- if(SCNetworkReachabilityScheduleWithRunLoop(reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode))
4195- {
4196- retVal = YES;
4197- }
4198- }
4199- return retVal;
4200-}
4201-
4202-- (void) stopNotifer
4203-{
4204- if(reachabilityRef!= NULL)
4205- {
4206- SCNetworkReachabilityUnscheduleFromRunLoop(reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
4207- }
4208-}
4209-
4210-- (void) dealloc
4211-{
4212- [self stopNotifer];
4213- if(reachabilityRef!= NULL)
4214- {
4215- CFRelease(reachabilityRef);
4216- }
4217- [super dealloc];
4218-}
4219-
4220-+ (Reachability*) reachabilityWithHostName: (NSString*) hostName;
4221-{
4222- Reachability* retVal = NULL;
4223- SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, [hostName UTF8String]);
4224- if(reachability!= NULL)
4225- {
4226- retVal= [[[self alloc] init] autorelease];
4227- if(retVal!= NULL)
4228- {
4229- retVal->reachabilityRef = reachability;
4230- retVal->localWiFiRef = NO;
4231- }
4232- }
4233- return retVal;
4234-}
4235-
4236-+ (Reachability*) reachabilityWithAddress: (const struct sockaddr_in*) hostAddress;
4237-{
4238- SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)hostAddress);
4239- Reachability* retVal = NULL;
4240- if(reachability!= NULL)
4241- {
4242- retVal= [[[self alloc] init] autorelease];
4243- if(retVal!= NULL)
4244- {
4245- retVal->reachabilityRef = reachability;
4246- retVal->localWiFiRef = NO;
4247- }
4248- }
4249- return retVal;
4250-}
4251-
4252-+ (Reachability*) reachabilityForInternetConnection;
4253-{
4254- struct sockaddr_in zeroAddress;
4255- bzero(&zeroAddress, sizeof(zeroAddress));
4256- zeroAddress.sin_len = sizeof(zeroAddress);
4257- zeroAddress.sin_family = AF_INET;
4258- return [self reachabilityWithAddress: &zeroAddress];
4259-}
4260-
4261-+ (Reachability*) reachabilityForLocalWiFi;
4262-{
4263- //[super init];
4264- struct sockaddr_in localWifiAddress;
4265- bzero(&localWifiAddress, sizeof(localWifiAddress));
4266- localWifiAddress.sin_len = sizeof(localWifiAddress);
4267- localWifiAddress.sin_family = AF_INET;
4268- // IN_LINKLOCALNETNUM is defined in <netinet/in.h> as 169.254.0.0
4269- localWifiAddress.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM);
4270- Reachability* retVal = [self reachabilityWithAddress: &localWifiAddress];
4271- if(retVal!= NULL)
4272- {
4273- retVal->localWiFiRef = YES;
4274- }
4275- return retVal;
4276-}
4277-
4278-#pragma mark Network Flag Handling
4279-
4280-- (NetworkStatus) localWiFiStatusForFlags: (SCNetworkReachabilityFlags) flags
4281-{
4282- PrintReachabilityFlags(flags, "localWiFiStatusForFlags");
4283-
4284- BOOL retVal = NotReachable;
4285- if((flags & kSCNetworkReachabilityFlagsReachable) && (flags & kSCNetworkReachabilityFlagsIsDirect))
4286- {
4287- retVal = ReachableViaWiFi;
4288- }
4289- return retVal;
4290-}
4291-
4292-- (NetworkStatus) networkStatusForFlags: (SCNetworkReachabilityFlags) flags
4293-{
4294- PrintReachabilityFlags(flags, "networkStatusForFlags");
4295- if ((flags & kSCNetworkReachabilityFlagsReachable) == 0)
4296- {
4297- // if target host is not reachable
4298- return NotReachable;
4299- }
4300-
4301- BOOL retVal = NotReachable;
4302-
4303- if ((flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0)
4304- {
4305- // if target host is reachable and no connection is required
4306- // then we'll assume (for now) that your on Wi-Fi
4307- retVal = ReachableViaWiFi;
4308- }
4309-
4310-
4311- if ((((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) ||
4312- (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0))
4313- {
4314- // ... and the connection is on-demand (or on-traffic) if the
4315- // calling application is using the CFSocketStream or higher APIs
4316-
4317- if ((flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0)
4318- {
4319- // ... and no [user] intervention is needed
4320- retVal = ReachableViaWiFi;
4321- }
4322- }
4323-
4324- if ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN)
4325- {
4326- // ... but WWAN connections are OK if the calling application
4327- // is using the CFNetwork (CFSocketStream?) APIs.
4328- retVal = ReachableViaWWAN;
4329- }
4330- return retVal;
4331-}
4332-
4333-- (BOOL) connectionRequired;
4334-{
4335- NSAssert(reachabilityRef != NULL, @"connectionRequired called with NULL reachabilityRef");
4336- SCNetworkReachabilityFlags flags;
4337- if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
4338- {
4339- return (flags & kSCNetworkReachabilityFlagsConnectionRequired);
4340- }
4341- return NO;
4342-}
4343-
4344-- (NetworkStatus) currentReachabilityStatus
4345-{
4346- NSAssert(reachabilityRef != NULL, @"currentNetworkStatus called with NULL reachabilityRef");
4347- NetworkStatus retVal = NotReachable;
4348- SCNetworkReachabilityFlags flags;
4349- if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
4350- {
4351- if(localWiFiRef)
4352- {
4353- retVal = [self localWiFiStatusForFlags: flags];
4354- }
4355- else
4356- {
4357- retVal = [self networkStatusForFlags: flags];
4358- }
4359- }
4360- return retVal;
4361-}
4362-@end
4363
4364=== added directory 'Dependencies/ShareKit'
4365=== added file 'Dependencies/ShareKit/.gitignore'
4366--- Dependencies/ShareKit/.gitignore 1970-01-01 00:00:00 +0000
4367+++ Dependencies/ShareKit/.gitignore 2012-10-23 16:44:18 +0000
4368@@ -0,0 +1,12 @@
4369+.DS_Store
4370+*~
4371+*.pbxuser
4372+*.perspective
4373+*.perspectivev3
4374+*.mode1v3
4375+*.xcworkspace
4376+*xcuserdata
4377+build
4378+.DS_Store
4379+Classes/ShareKit/SHKConfig.h
4380+DerivedData
4381\ No newline at end of file
4382
4383=== added file 'Dependencies/ShareKit/.gitmodules'
4384--- Dependencies/ShareKit/.gitmodules 1970-01-01 00:00:00 +0000
4385+++ Dependencies/ShareKit/.gitmodules 2012-10-23 16:44:18 +0000
4386@@ -0,0 +1,15 @@
4387+[submodule "Submodules/facebook-ios-sdk"]
4388+ path = Submodules/facebook-ios-sdk
4389+ url = https://github.com/ShareKit/facebook-ios-sdk.git
4390+[submodule "Submodules/JSONKit"]
4391+ path = Submodules/JSONKit
4392+ url = https://github.com/johnezang/JSONKit.git
4393+[submodule "Submodules/sskeychain"]
4394+ path = Submodules/sskeychain
4395+ url = https://github.com/samsoffes/sskeychain.git
4396+[submodule "Submodules/objectiveflickr"]
4397+ path = Submodules/objectiveflickr
4398+ url = https://github.com/lukhnos/objectiveflickr.git
4399+[submodule "Submodules/evernote-ios-sdk"]
4400+ path = Submodules/evernote-ios-sdk
4401+ url = https://github.com/evernote/evernote-sdk-ios.git
4402
4403=== added directory 'Dependencies/ShareKit/Classes'
4404=== added directory 'Dependencies/ShareKit/Classes/Example'
4405=== added file 'Dependencies/ShareKit/Classes/Example/ExampleShareFile.h'
4406--- Dependencies/ShareKit/Classes/Example/ExampleShareFile.h 1970-01-01 00:00:00 +0000
4407+++ Dependencies/ShareKit/Classes/Example/ExampleShareFile.h 2012-10-23 16:44:18 +0000
4408@@ -0,0 +1,38 @@
4409+//
4410+// ExampleShareFile.h
4411+// ShareKit
4412+//
4413+// Created by Nathan Weiner on 6/29/10.
4414+
4415+//
4416+// Permission is hereby granted, free of charge, to any person obtaining a copy
4417+// of this software and associated documentation files (the "Software"), to deal
4418+// in the Software without restriction, including without limitation the rights
4419+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4420+// copies of the Software, and to permit persons to whom the Software is
4421+// furnished to do so, subject to the following conditions:
4422+//
4423+// The above copyright notice and this permission notice shall be included in
4424+// all copies or substantial portions of the Software.
4425+//
4426+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4427+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4428+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4429+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4430+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4431+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
4432+// THE SOFTWARE.
4433+//
4434+//
4435+
4436+#import <Foundation/Foundation.h>
4437+
4438+
4439+@interface ExampleShareFile : UIViewController <UIWebViewDelegate>
4440+{
4441+ UIWebView *webView;
4442+}
4443+
4444+@property (nonatomic, retain) UIWebView *webView;
4445+
4446+@end
4447
4448=== added file 'Dependencies/ShareKit/Classes/Example/ExampleShareFile.m'
4449--- Dependencies/ShareKit/Classes/Example/ExampleShareFile.m 1970-01-01 00:00:00 +0000
4450+++ Dependencies/ShareKit/Classes/Example/ExampleShareFile.m 2012-10-23 16:44:18 +0000
4451@@ -0,0 +1,84 @@
4452+//
4453+// ExampleShareFile.m
4454+// ShareKit
4455+//
4456+// Created by Nathan Weiner on 6/29/10.
4457+
4458+//
4459+// Permission is hereby granted, free of charge, to any person obtaining a copy
4460+// of this software and associated documentation files (the "Software"), to deal
4461+// in the Software without restriction, including without limitation the rights
4462+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4463+// copies of the Software, and to permit persons to whom the Software is
4464+// furnished to do so, subject to the following conditions:
4465+//
4466+// The above copyright notice and this permission notice shall be included in
4467+// all copies or substantial portions of the Software.
4468+//
4469+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4470+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4471+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4472+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4473+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4474+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
4475+// THE SOFTWARE.
4476+//
4477+//
4478+
4479+#import "ExampleShareFile.h"
4480+#import "SHK.h"
4481+#import "SHKActionSheet.h"
4482+
4483+@implementation ExampleShareFile
4484+
4485+@synthesize webView;
4486+
4487+- (void)dealloc
4488+{
4489+ [webView release];
4490+ [super dealloc];
4491+}
4492+
4493+- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
4494+{
4495+ if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
4496+ {
4497+ self.toolbarItems = [NSArray arrayWithObjects:
4498+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease],
4499+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(share)] autorelease],
4500+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease],
4501+ nil
4502+ ];
4503+ }
4504+
4505+ return self;
4506+}
4507+
4508+- (void)loadView
4509+{
4510+ self.webView = [[[UIWebView alloc] initWithFrame:CGRectZero] autorelease];
4511+ webView.delegate = self;
4512+ webView.scalesPageToFit = YES;
4513+ [webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"example.pdf"]]]];
4514+
4515+ self.view = webView;
4516+}
4517+
4518+- (void)share
4519+{
4520+ NSString *filePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"example.pdf"];
4521+ NSData *file = [NSData dataWithContentsOfFile:filePath];
4522+
4523+ SHKItem *item = [SHKItem file:file filename:@"Awesome.pdf" mimeType:@"application/pdf" title:@"My Awesome PDF"];
4524+ item.tags = [NSArray arrayWithObjects:[[NSDate date] description], @"pdf document", @"sharekit", nil];
4525+ SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
4526+ [SHK setRootViewController:self];
4527+ [actionSheet showFromToolbar:self.navigationController.toolbar];
4528+}
4529+
4530+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
4531+{
4532+ return YES;
4533+}
4534+
4535+@end
4536
4537=== added file 'Dependencies/ShareKit/Classes/Example/ExampleShareImage.h'
4538--- Dependencies/ShareKit/Classes/Example/ExampleShareImage.h 1970-01-01 00:00:00 +0000
4539+++ Dependencies/ShareKit/Classes/Example/ExampleShareImage.h 2012-10-23 16:44:18 +0000
4540@@ -0,0 +1,38 @@
4541+//
4542+// ExampleShareImage.h
4543+// ShareKit
4544+//
4545+// Created by Nathan Weiner on 6/18/10.
4546+
4547+//
4548+// Permission is hereby granted, free of charge, to any person obtaining a copy
4549+// of this software and associated documentation files (the "Software"), to deal
4550+// in the Software without restriction, including without limitation the rights
4551+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4552+// copies of the Software, and to permit persons to whom the Software is
4553+// furnished to do so, subject to the following conditions:
4554+//
4555+// The above copyright notice and this permission notice shall be included in
4556+// all copies or substantial portions of the Software.
4557+//
4558+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4559+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4560+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4561+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4562+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4563+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
4564+// THE SOFTWARE.
4565+//
4566+//
4567+
4568+#import <UIKit/UIKit.h>
4569+
4570+
4571+@interface ExampleShareImage : UIViewController
4572+{
4573+ UIImageView *imageView;
4574+}
4575+
4576+@property (nonatomic, retain) UIImageView *imageView;
4577+
4578+@end
4579
4580=== added file 'Dependencies/ShareKit/Classes/Example/ExampleShareImage.m'
4581--- Dependencies/ShareKit/Classes/Example/ExampleShareImage.m 1970-01-01 00:00:00 +0000
4582+++ Dependencies/ShareKit/Classes/Example/ExampleShareImage.m 2012-10-23 16:44:18 +0000
4583@@ -0,0 +1,89 @@
4584+ //
4585+// ExampleShareImage.m
4586+// ShareKit
4587+//
4588+// Created by Nathan Weiner on 6/18/10.
4589+
4590+//
4591+// Permission is hereby granted, free of charge, to any person obtaining a copy
4592+// of this software and associated documentation files (the "Software"), to deal
4593+// in the Software without restriction, including without limitation the rights
4594+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4595+// copies of the Software, and to permit persons to whom the Software is
4596+// furnished to do so, subject to the following conditions:
4597+//
4598+// The above copyright notice and this permission notice shall be included in
4599+// all copies or substantial portions of the Software.
4600+//
4601+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4602+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4603+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4604+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4605+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4606+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
4607+// THE SOFTWARE.
4608+//
4609+//
4610+
4611+#import "ExampleShareImage.h"
4612+#import "SHKItem.h"
4613+#import "SHKActionSheet.h"
4614+
4615+@implementation ExampleShareImage
4616+
4617+@synthesize imageView;
4618+
4619+- (void)dealloc
4620+{
4621+ [imageView release];
4622+ [super dealloc];
4623+}
4624+
4625+- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
4626+{
4627+ if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
4628+ {
4629+ self.toolbarItems = [NSArray arrayWithObjects:
4630+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease],
4631+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(share)] autorelease],
4632+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease],
4633+ nil
4634+ ];
4635+ }
4636+
4637+ return self;
4638+}
4639+
4640+- (void)loadView
4641+{
4642+ [super loadView];
4643+
4644+ self.imageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sanFran.jpg"]] autorelease];
4645+
4646+ imageView.frame = CGRectMake(0,0,self.view.bounds.size.width,self.view.bounds.size.height);
4647+
4648+ [self.view addSubview:imageView];
4649+}
4650+
4651+- (void)share
4652+{
4653+ SHKItem *item = [SHKItem image:imageView.image title:@"San Francisco"];
4654+
4655+ /* optional examples
4656+ item.tags = [NSArray arrayWithObjects:@"bay bridge", @"architecture", @"california", nil];
4657+
4658+ //give a source rect in the coords of the view set with setRootViewController:
4659+ item.popOverSourceRect = [self.navigationController.toolbar convertRect:self.navigationController.toolbar.bounds toView:self.view];
4660+ */
4661+
4662+ SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
4663+ [SHK setRootViewController:self];
4664+ [actionSheet showFromToolbar:self.navigationController.toolbar];
4665+}
4666+
4667+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
4668+{
4669+ return YES;
4670+}
4671+
4672+@end
4673
4674=== added file 'Dependencies/ShareKit/Classes/Example/ExampleShareLink.h'
4675--- Dependencies/ShareKit/Classes/Example/ExampleShareLink.h 1970-01-01 00:00:00 +0000
4676+++ Dependencies/ShareKit/Classes/Example/ExampleShareLink.h 2012-10-23 16:44:18 +0000
4677@@ -0,0 +1,38 @@
4678+//
4679+// ExampleShareLink.h
4680+// ShareKit
4681+//
4682+// Created by Nathan Weiner on 6/17/10.
4683+
4684+//
4685+// Permission is hereby granted, free of charge, to any person obtaining a copy
4686+// of this software and associated documentation files (the "Software"), to deal
4687+// in the Software without restriction, including without limitation the rights
4688+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4689+// copies of the Software, and to permit persons to whom the Software is
4690+// furnished to do so, subject to the following conditions:
4691+//
4692+// The above copyright notice and this permission notice shall be included in
4693+// all copies or substantial portions of the Software.
4694+//
4695+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4696+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4697+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4698+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4699+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4700+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
4701+// THE SOFTWARE.
4702+//
4703+//
4704+
4705+#import <UIKit/UIKit.h>
4706+
4707+
4708+@interface ExampleShareLink : UIViewController <UIWebViewDelegate>
4709+{
4710+ UIWebView *webView;
4711+}
4712+
4713+@property (nonatomic, retain) UIWebView *webView;
4714+
4715+@end
4716
4717=== added file 'Dependencies/ShareKit/Classes/Example/ExampleShareLink.m'
4718--- Dependencies/ShareKit/Classes/Example/ExampleShareLink.m 1970-01-01 00:00:00 +0000
4719+++ Dependencies/ShareKit/Classes/Example/ExampleShareLink.m 2012-10-23 16:44:18 +0000
4720@@ -0,0 +1,90 @@
4721+ //
4722+// ExampleShareLink.m
4723+// ShareKit
4724+//
4725+// Created by Nathan Weiner on 6/17/10.
4726+
4727+//
4728+// Permission is hereby granted, free of charge, to any person obtaining a copy
4729+// of this software and associated documentation files (the "Software"), to deal
4730+// in the Software without restriction, including without limitation the rights
4731+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4732+// copies of the Software, and to permit persons to whom the Software is
4733+// furnished to do so, subject to the following conditions:
4734+//
4735+// The above copyright notice and this permission notice shall be included in
4736+// all copies or substantial portions of the Software.
4737+//
4738+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4739+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4740+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4741+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4742+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4743+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
4744+// THE SOFTWARE.
4745+//
4746+//
4747+
4748+#import "ExampleShareLink.h"
4749+#import "SHK.h"
4750+
4751+@implementation ExampleShareLink
4752+
4753+@synthesize webView;
4754+
4755+- (void)dealloc
4756+{
4757+ [webView release];
4758+ [super dealloc];
4759+}
4760+
4761+- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
4762+{
4763+ if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
4764+ {
4765+ self.toolbarItems = [NSArray arrayWithObjects:
4766+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease],
4767+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(share)] autorelease],
4768+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease],
4769+ nil
4770+ ];
4771+ }
4772+
4773+ return self;
4774+}
4775+
4776+- (void)share
4777+{
4778+ SHKItem *item = [SHKItem URL:webView.request.URL title:[webView pageTitle] contentType:(SHKURLContentTypeWebpage)];
4779+
4780+ /* bellow are examples how to preload SHKItem with some custom sharer specific settings. You can prefill them ad hoc during each particular SHKItem createion, or set them globally in your configurator, so that every SHKItem is prefilled with the same values. More info in SHKItem.h or DefaultSHKConfigurator.m.
4781+
4782+ SHKItem *item = [SHKItem URL:[NSURL URLWithString:@"http://www.youtube.com/watch?v=3t8MeE8Ik4Y"] title:@"Big bang" contentType:SHKURLContentTypeVideo];
4783+ item.facebookURLSharePictureURI = @"http://www.state.gov/cms_images/india_tajmahal_2003_06_252.jpg";
4784+ item.facebookURLShareDescription = @"description text";
4785+ item.tags = [NSArray arrayWithObjects:@"apple inc.",@"computers",@"mac", nil];
4786+ item.mailToRecipients = [NSArray arrayWithObjects:@"frodo@middle-earth.me", @"gandalf@middle-earth.me", nil];
4787+ item.textMessageToRecipients = [NSArray arrayWithObjects: @"581347615", @"581344543", nil];
4788+ */
4789+
4790+ SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
4791+ [SHK setRootViewController:self];
4792+ [actionSheet showFromToolbar:self.navigationController.toolbar];
4793+}
4794+
4795+- (void)loadView
4796+{
4797+ self.webView = [[[UIWebView alloc] initWithFrame:CGRectZero] autorelease];
4798+ webView.delegate = self;
4799+ webView.scalesPageToFit = YES;
4800+ [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://apple.com"]]];
4801+
4802+ self.view = webView;
4803+}
4804+
4805+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
4806+{
4807+ return YES;
4808+}
4809+
4810+@end
4811
4812=== added file 'Dependencies/ShareKit/Classes/Example/ExampleShareText.h'
4813--- Dependencies/ShareKit/Classes/Example/ExampleShareText.h 1970-01-01 00:00:00 +0000
4814+++ Dependencies/ShareKit/Classes/Example/ExampleShareText.h 2012-10-23 16:44:18 +0000
4815@@ -0,0 +1,38 @@
4816+//
4817+// ExampleShareText.h
4818+// ShareKit
4819+//
4820+// Created by Nathan Weiner on 6/18/10.
4821+
4822+//
4823+// Permission is hereby granted, free of charge, to any person obtaining a copy
4824+// of this software and associated documentation files (the "Software"), to deal
4825+// in the Software without restriction, including without limitation the rights
4826+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4827+// copies of the Software, and to permit persons to whom the Software is
4828+// furnished to do so, subject to the following conditions:
4829+//
4830+// The above copyright notice and this permission notice shall be included in
4831+// all copies or substantial portions of the Software.
4832+//
4833+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4834+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4835+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4836+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4837+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4838+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
4839+// THE SOFTWARE.
4840+//
4841+//
4842+
4843+#import <UIKit/UIKit.h>
4844+
4845+
4846+@interface ExampleShareText : UIViewController
4847+{
4848+ UITextView *textView;
4849+}
4850+
4851+@property (nonatomic, retain) UITextView *textView;
4852+
4853+@end
4854
4855=== added file 'Dependencies/ShareKit/Classes/Example/ExampleShareText.m'
4856--- Dependencies/ShareKit/Classes/Example/ExampleShareText.m 1970-01-01 00:00:00 +0000
4857+++ Dependencies/ShareKit/Classes/Example/ExampleShareText.m 2012-10-23 16:44:18 +0000
4858@@ -0,0 +1,90 @@
4859+ //
4860+// ExampleShareText.m
4861+// ShareKit
4862+//
4863+// Created by Nathan Weiner on 6/18/10.
4864+//
4865+// Permission is hereby granted, free of charge, to any person obtaining a copy
4866+// of this software and associated documentation files (the "Software"), to deal
4867+// in the Software without restriction, including without limitation the rights
4868+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4869+// copies of the Software, and to permit persons to whom the Software is
4870+// furnished to do so, subject to the following conditions:
4871+//
4872+// The above copyright notice and this permission notice shall be included in
4873+// all copies or substantial portions of the Software.
4874+//
4875+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4876+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4877+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4878+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4879+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4880+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
4881+// THE SOFTWARE.
4882+//
4883+
4884+#import "ExampleShareText.h"
4885+#import "SHKItem.h"
4886+#import "SHKActionSheet.h"
4887+
4888+@implementation ExampleShareText
4889+
4890+@synthesize textView;
4891+
4892+- (void)dealloc
4893+{
4894+ [textView release];
4895+ [super dealloc];
4896+}
4897+
4898+- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
4899+{
4900+ if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
4901+ {
4902+ self.toolbarItems = [NSArray arrayWithObjects:
4903+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease],
4904+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(share)] autorelease],
4905+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease],
4906+ nil
4907+ ];
4908+ }
4909+
4910+ return self;
4911+}
4912+
4913+- (void)loadView
4914+{
4915+ [super loadView];
4916+
4917+ self.textView = [[[UITextView alloc] initWithFrame:CGRectMake(0,0,self.view.bounds.size.width,self.view.bounds.size.height)] autorelease];
4918+ [self.view addSubview:textView];
4919+
4920+ textView.text = @"This is a chunk of text. If you highlight it, you'll be able to share the selection. If you tap the share button below, it will share all of it.";
4921+ textView.editable = NO;
4922+}
4923+
4924+- (void)share
4925+{
4926+ NSString *text;
4927+
4928+ if (textView.selectedRange.length > 0)
4929+ text = [textView.text substringWithRange:textView.selectedRange];
4930+
4931+ else
4932+ text = textView.text;
4933+
4934+
4935+ SHKItem *item = [SHKItem text:text];
4936+ item.tags = [NSArray arrayWithObjects:@"sharekit", @"testing", @"text example", nil];
4937+ SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
4938+ [SHK setRootViewController:self];
4939+ [actionSheet showFromToolbar:self.navigationController.toolbar];
4940+}
4941+
4942+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
4943+{
4944+ return YES;
4945+}
4946+
4947+
4948+@end
4949
4950=== added file 'Dependencies/ShareKit/Classes/Example/RootViewController.h'
4951--- Dependencies/ShareKit/Classes/Example/RootViewController.h 1970-01-01 00:00:00 +0000
4952+++ Dependencies/ShareKit/Classes/Example/RootViewController.h 2012-10-23 16:44:18 +0000
4953@@ -0,0 +1,14 @@
4954+//
4955+// RootViewController.h
4956+// ShareKit
4957+//
4958+// Created by Nathan Weiner on 6/4/10.
4959+// Copyright Idea Shower, LLC 2010. All rights reserved.
4960+//
4961+
4962+#import <UIKit/UIKit.h>
4963+
4964+@interface RootViewController : UITableViewController {
4965+}
4966+
4967+@end
4968
4969=== added file 'Dependencies/ShareKit/Classes/Example/RootViewController.m'
4970--- Dependencies/ShareKit/Classes/Example/RootViewController.m 1970-01-01 00:00:00 +0000
4971+++ Dependencies/ShareKit/Classes/Example/RootViewController.m 2012-10-23 16:44:18 +0000
4972@@ -0,0 +1,139 @@
4973+//
4974+// RootViewController.m
4975+// ShareKit
4976+//
4977+// Created by Nathan Weiner on 6/4/10.
4978+// Copyright Idea Shower, LLC 2010. All rights reserved.
4979+//
4980+
4981+#import "RootViewController.h"
4982+#import "ExampleShareLink.h"
4983+#import "ExampleShareImage.h"
4984+#import "ExampleShareText.h"
4985+#import "ExampleShareFile.h"
4986+#import "SHK.h"
4987+
4988+@implementation RootViewController
4989+
4990+- (void)loadView
4991+{
4992+ [super loadView];
4993+
4994+ self.toolbarItems = [NSArray arrayWithObjects:
4995+ [[[UIBarButtonItem alloc] initWithTitle:SHKLocalizedString(@"Logout") style:UIBarButtonItemStyleBordered target:self action:@selector(logout)] autorelease],
4996+ nil
4997+ ];
4998+}
4999+
5000+#pragma mark -
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches