├── .travis.yml
├── Benchmark.zip
├── Benchmark
├── ModelBenchmark.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── WHC.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ ├── .xcassets
│ │ └── Asset.xcasset
│ │ └── WHC.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── ModelBenchmark.xcscheme
│ │ └── xcschememanagement.plist
├── ModelBenchmark
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Base.lproj
│ │ ├── LaunchScreen.xib
│ │ └── Main.storyboard
│ ├── Cartfile.bak
│ ├── DateFormatter.h
│ ├── DateFormatter.m
│ ├── FEWeiboModel.h
│ ├── FEWeiboModel.m
│ ├── GitHubUser.h
│ ├── GitHubUser.m
│ ├── GithubUserBenchmark.swift.bak
│ ├── GithubUserObjectMapper.swift.bak
│ ├── Images.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── Info.plist
│ ├── JSWeiboModel.h
│ ├── JSWeiboModel.m
│ ├── MJWeiboModel.h
│ ├── MJWeiboModel.m
│ ├── MTWeiboModel.h
│ ├── MTWeiboModel.m
│ ├── ModelBenchmark-Bridging-Header.h
│ ├── Test.h
│ ├── Test.json
│ ├── Test.m
│ ├── ViewController.h
│ ├── ViewController.m
│ ├── WHCWeiboModel.h
│ ├── WHCWeiboModel.m
│ ├── WHC_Model
│ │ ├── NSObject+WHC_Model.h
│ │ └── NSObject+WHC_Model.m
│ ├── YYModel
│ │ ├── NSObject+YYModel.h
│ │ ├── NSObject+YYModel.m
│ │ ├── YYClassInfo.h
│ │ ├── YYClassInfo.m
│ │ └── YYModel.h
│ ├── YYWeiboModel.h
│ ├── YYWeiboModel.m
│ ├── main.m
│ ├── user.json
│ └── weibo.json
├── Vendor
│ ├── FastEasyMapping
│ │ ├── Core
│ │ │ ├── Assignment Policy
│ │ │ │ ├── FEMAssignmentPolicy.h
│ │ │ │ ├── FEMAssignmentPolicy.m
│ │ │ │ ├── FEMRelationshipAssignmentContext+Internal.h
│ │ │ │ ├── FEMRelationshipAssignmentContext.h
│ │ │ │ └── FEMRelationshipAssignmentContext.m
│ │ │ ├── Cache
│ │ │ │ ├── FEMManagedObjectCache.h
│ │ │ │ └── FEMManagedObjectCache.m
│ │ │ ├── Deserializer
│ │ │ │ ├── FEMDeserializer.h
│ │ │ │ ├── FEMDeserializer.m
│ │ │ │ ├── FEMManagedObjectDeserializer.h
│ │ │ │ └── FEMObjectDeserializer.h
│ │ │ ├── Mapping
│ │ │ │ ├── FEMAttribute.h
│ │ │ │ ├── FEMAttribute.m
│ │ │ │ ├── FEMManagedObjectMapping.h
│ │ │ │ ├── FEMMapping.h
│ │ │ │ ├── FEMMapping.m
│ │ │ │ ├── FEMObjectMapping.h
│ │ │ │ ├── FEMProperty.h
│ │ │ │ ├── FEMRelationship.h
│ │ │ │ └── FEMRelationship.m
│ │ │ ├── Serializer
│ │ │ │ ├── FEMSerializer.h
│ │ │ │ └── FEMSerializer.m
│ │ │ └── Store
│ │ │ │ ├── FEMManagedObjectStore.h
│ │ │ │ ├── FEMManagedObjectStore.m
│ │ │ │ ├── FEMObjectStore.h
│ │ │ │ └── FEMObjectStore.m
│ │ ├── Extensions
│ │ │ ├── Collection
│ │ │ │ ├── FEMExcludableCollection.h
│ │ │ │ ├── FEMExcludableCollection.m
│ │ │ │ ├── FEMMergeableCollection.h
│ │ │ │ └── FEMMergeableCollection.m
│ │ │ └── Foundation
│ │ │ │ ├── NSArray+FEMPropertyRepresentation.h
│ │ │ │ ├── NSArray+FEMPropertyRepresentation.m
│ │ │ │ ├── NSObject+FEMKVCExtension.h
│ │ │ │ └── NSObject+FEMKVCExtension.m
│ │ ├── FastEasyMapping.h
│ │ └── Utility
│ │ │ ├── FEMMappingUtility.h
│ │ │ ├── FEMMappingUtility.m
│ │ │ ├── FEMRepresentationUtility.h
│ │ │ ├── FEMRepresentationUtility.m
│ │ │ ├── FEMTypeIntrospection.h
│ │ │ ├── FEMTypeIntrospection.m
│ │ │ └── FEMTypes.h
│ ├── JSONModel
│ │ ├── JSONModel
│ │ │ ├── JSONModel.h
│ │ │ ├── JSONModel.m
│ │ │ ├── JSONModelArray.h
│ │ │ ├── JSONModelArray.m
│ │ │ ├── JSONModelClassProperty.h
│ │ │ ├── JSONModelClassProperty.m
│ │ │ ├── JSONModelError.h
│ │ │ └── JSONModelError.m
│ │ ├── JSONModelCategories
│ │ │ ├── NSArray+JSONModel.h
│ │ │ └── NSArray+JSONModel.m
│ │ ├── JSONModelLib.h
│ │ ├── JSONModelNetworking
│ │ │ ├── JSONAPI.h
│ │ │ ├── JSONAPI.m
│ │ │ ├── JSONHTTPClient.h
│ │ │ ├── JSONHTTPClient.m
│ │ │ ├── JSONModel+networking.h
│ │ │ └── JSONModel+networking.m
│ │ └── JSONModelTransformations
│ │ │ ├── JSONKeyMapper.h
│ │ │ ├── JSONKeyMapper.m
│ │ │ ├── JSONValueTransformer.h
│ │ │ └── JSONValueTransformer.m
│ ├── MJExtension
│ │ ├── MJDictionaryCache.h
│ │ ├── MJDictionaryCache.m
│ │ ├── MJExtension.h
│ │ ├── MJExtensionConst.h
│ │ ├── MJExtensionConst.m
│ │ ├── MJFoundation.h
│ │ ├── MJFoundation.m
│ │ ├── MJProperty.h
│ │ ├── MJProperty.m
│ │ ├── MJPropertyKey.h
│ │ ├── MJPropertyKey.m
│ │ ├── MJPropertyType.h
│ │ ├── MJPropertyType.m
│ │ ├── NSObject+MJClass.h
│ │ ├── NSObject+MJClass.m
│ │ ├── NSObject+MJCoding.h
│ │ ├── NSObject+MJCoding.m
│ │ ├── NSObject+MJKeyValue.h
│ │ ├── NSObject+MJKeyValue.m
│ │ ├── NSObject+MJProperty.h
│ │ ├── NSObject+MJProperty.m
│ │ ├── NSString+MJExtension.h
│ │ └── NSString+MJExtension.m
│ ├── Mantle
│ │ ├── MTLJSONAdapter.h
│ │ ├── MTLJSONAdapter.m
│ │ ├── MTLModel+NSCoding.h
│ │ ├── MTLModel+NSCoding.m
│ │ ├── MTLModel.h
│ │ ├── MTLModel.m
│ │ ├── MTLReflection.h
│ │ ├── MTLReflection.m
│ │ ├── MTLTransformerErrorHandling.h
│ │ ├── MTLTransformerErrorHandling.m
│ │ ├── MTLValueTransformer.h
│ │ ├── MTLValueTransformer.m
│ │ ├── Mantle.h
│ │ ├── NSArray+MTLManipulationAdditions.h
│ │ ├── NSArray+MTLManipulationAdditions.m
│ │ ├── NSDictionary+MTLJSONKeyPath.h
│ │ ├── NSDictionary+MTLJSONKeyPath.m
│ │ ├── NSDictionary+MTLManipulationAdditions.h
│ │ ├── NSDictionary+MTLManipulationAdditions.m
│ │ ├── NSDictionary+MTLMappingAdditions.h
│ │ ├── NSDictionary+MTLMappingAdditions.m
│ │ ├── NSError+MTLModelException.h
│ │ ├── NSError+MTLModelException.m
│ │ ├── NSObject+MTLComparisonAdditions.h
│ │ ├── NSObject+MTLComparisonAdditions.m
│ │ ├── NSValueTransformer+MTLInversionAdditions.h
│ │ ├── NSValueTransformer+MTLInversionAdditions.m
│ │ ├── NSValueTransformer+MTLPredefinedTransformerAdditions.h
│ │ ├── NSValueTransformer+MTLPredefinedTransformerAdditions.m
│ │ └── extobjc
│ │ │ ├── EXTKeyPathCoding.h
│ │ │ ├── EXTRuntimeExtensions.h
│ │ │ ├── EXTRuntimeExtensions.m
│ │ │ ├── EXTScope.h
│ │ │ ├── EXTScope.m
│ │ │ └── metamacros.h
│ ├── WHC_Model
│ │ ├── NSObject+WHC_Model.h
│ │ └── NSObject+WHC_Model.m
│ └── YYModel
│ │ ├── NSObject+YYModel.h
│ │ ├── NSObject+YYModel.m
│ │ ├── YYClassInfo.h
│ │ ├── YYClassInfo.m
│ │ └── YYModel.h
├── a.png
└── b.png
├── LICENSE
├── README.md
├── Result
├── a.png
└── b.png
├── WHC_Model.podspec
├── WHC_Model.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ └── WHC.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
└── xcuserdata
│ ├── .xcassets
│ └── build.file
│ └── WHC.xcuserdatad
│ ├── xcdebugger
│ └── Breakpoints_v2.xcbkptlist
│ └── xcschemes
│ ├── WHC_Model.xcscheme
│ └── xcschememanagement.plist
├── WHC_Model
├── AppDelegate.h
├── AppDelegate.m
├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
├── Info.plist
├── Model
│ ├── ModelObject.h
│ └── ModelObject.m
├── ViewController.h
├── ViewController.m
├── json
│ └── ModelObject.json
└── main.m
└── WHC_ModelKit
├── NSObject+WHC_Model.h
└── NSObject+WHC_Model.m
/.travis.yml:
--------------------------------------------------------------------------------
1 | osx_image: xcode8
2 | language: objective-c
3 | xcode_project: WHC_Model.xcodeproj # path to your xcodeproj folder
4 | xcode_schemes: WHC_Model
--------------------------------------------------------------------------------
/Benchmark.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/netyouli/WHC_Model/1c8008b966b91b0255666146e4c0423ec4d5c00e/Benchmark.zip
--------------------------------------------------------------------------------
/Benchmark/ModelBenchmark.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Benchmark/ModelBenchmark.xcodeproj/project.xcworkspace/xcuserdata/WHC.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/netyouli/WHC_Model/1c8008b966b91b0255666146e4c0423ec4d5c00e/Benchmark/ModelBenchmark.xcodeproj/project.xcworkspace/xcuserdata/WHC.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/Benchmark/ModelBenchmark.xcodeproj/xcuserdata/.xcassets/Asset.xcasset:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/netyouli/WHC_Model/1c8008b966b91b0255666146e4c0423ec4d5c00e/Benchmark/ModelBenchmark.xcodeproj/xcuserdata/.xcassets/Asset.xcasset
--------------------------------------------------------------------------------
/Benchmark/ModelBenchmark.xcodeproj/xcuserdata/WHC.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
14 |
15 |
16 |
18 |
30 |
31 |
32 |
34 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/Benchmark/ModelBenchmark.xcodeproj/xcuserdata/WHC.xcuserdatad/xcschemes/ModelBenchmark.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/Benchmark/ModelBenchmark.xcodeproj/xcuserdata/WHC.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | ModelBenchmark.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | D9B1937A1BAC714D00F93933
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Benchmark/ModelBenchmark/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // ModelBenchmark
4 | //
5 | // Created by ibireme on 15/9/18.
6 | // Copyright (c) 2015 ibireme. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/Benchmark/ModelBenchmark/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // ModelBenchmark
4 | //
5 | // Created by ibireme on 15/9/18.
6 | // Copyright (c) 2015 ibireme. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 | @end
13 |
14 | @implementation AppDelegate
15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
16 | return YES;
17 | }
18 | @end
19 |
--------------------------------------------------------------------------------
/Benchmark/ModelBenchmark/Base.lproj/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
22 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/Benchmark/ModelBenchmark/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/Benchmark/ModelBenchmark/Cartfile.bak:
--------------------------------------------------------------------------------
1 | github "Hearst-DD/ObjectMapper"
2 |
3 | github "thoughtbot/Argo"
4 | github "thoughtbot/Curry"
5 |
6 | github "isair/JSONHelper"
7 | github "ovenbits/ModelRocket"
--------------------------------------------------------------------------------
/Benchmark/ModelBenchmark/DateFormatter.h:
--------------------------------------------------------------------------------
1 | //
2 | // DateFormatter.h
3 | // ModelBenchmark
4 | //
5 | // Created by ibireme on 15/9/18.
6 | // Copyright (c) 2015 ibireme. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface DateFormatter : NSObject
12 | + (NSDateFormatter *)githubDataFormatter;
13 | + (NSDateFormatter *)weiboDataFormatter;
14 | @end
15 |
--------------------------------------------------------------------------------
/Benchmark/ModelBenchmark/DateFormatter.m:
--------------------------------------------------------------------------------
1 | //
2 | // DateFormatter.m
3 | // ModelBenchmark
4 | //
5 | // Created by ibireme on 15/9/18.
6 | // Copyright (c) 2015 ibireme. All rights reserved.
7 | //
8 |
9 | #import "DateFormatter.h"
10 | #import "JSONModel.h"
11 |
12 | @implementation DateFormatter
13 | + (NSDateFormatter *)githubDataFormatter {
14 | static NSDateFormatter *formatter;
15 | static dispatch_once_t onceToken;
16 | dispatch_once(&onceToken, ^{
17 | formatter = [[NSDateFormatter alloc] init];
18 | formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
19 | formatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ssZ";
20 | });
21 | return formatter;
22 | }
23 | + (NSDateFormatter *)weiboDataFormatter {
24 | static NSDateFormatter *formatter;
25 | static dispatch_once_t onceToken;
26 | dispatch_once(&onceToken, ^{
27 | formatter = [[NSDateFormatter alloc] init];
28 | formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
29 | formatter.dateFormat = @"EEE MMM dd HH:mm:ss Z yyyy";
30 | });
31 | return formatter;
32 | }
33 | @end
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/Benchmark/ModelBenchmark/GithubUserBenchmark.swift.bak:
--------------------------------------------------------------------------------
1 | import Foundation
2 | import QuartzCore
3 |
4 | @objc class GithubUserBenchmark : NSObject {
5 | static func benchmark() {
6 |
7 | GithubUserObjectMapper.benchmark()
8 | }
9 | }
--------------------------------------------------------------------------------
/Benchmark/ModelBenchmark/GithubUserObjectMapper.swift.bak:
--------------------------------------------------------------------------------
1 | import Foundation
2 | import QuartzCore
3 | import ObjectMapper
4 |
5 | extension GithubUserObjectMapper {
6 | static func benchmark() {
7 | let path = NSBundle.mainBundle().pathForResource("user", ofType:"json")
8 | let data = NSData(contentsOfFile: path!)
9 | let json: NSDictionary?
10 | do {
11 | json = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.AllowFragments) as? NSDictionary
12 | } catch let error {
13 | print(error)
14 | json = nil
15 | }
16 |
17 | print("ObjectMapper from json to json archive")
18 | let start = CACurrentMediaTime()
19 | for _ in 1...10000 {
20 | _ = Mapper().map(json)
21 | }
22 | let end = CACurrentMediaTime()
23 | let time = (end - start) * 1000.0
24 | print("\(time) ms") // too slow...
25 | }
26 | }
27 |
28 | class GithubUserObjectMapper : Mappable {
29 | var login: String?
30 | var userID: UInt64?
31 | var avatarURL: String?
32 | var gravatarID: String?
33 | var url: String?
34 | var htmlURL: String?
35 | var followersURL: String?
36 | var followingURL: String?
37 | var gistsURL: String?
38 | var starredURL: String?
39 | var subscriptionsURL: String?
40 | var organizationsURL: String?
41 | var reposURL: String?
42 | var eventsURL: String?
43 | var receivedEventsURL: String?
44 | var type: String?
45 | var siteAdmin : Bool?
46 | var name: String?
47 | var company: String?
48 | var blog: String?
49 | var location: String?
50 | var email: String?
51 | var hireable: String?
52 | var bio: String?
53 | var publicRepos: Int?
54 | var publicGists: Int?
55 | var followers: Int?
56 | var following: Int?
57 | var createdAt: NSDate?
58 | var updatedAt: NSDate?
59 | var test: NSValue?
60 |
61 | required init?(_ map: Map){
62 |
63 | }
64 |
65 | func mapping(map: Map) {
66 | login <- map["login"]
67 | userID <- map["id"]
68 | avatarURL <- map["avatar_url"]
69 | gravatarID <- map["gravatar_id"]
70 | url <- map["url"]
71 | htmlURL <- map["html_url"]
72 | followersURL <- map["followers_url"]
73 | followingURL <- map["following_url"]
74 | gistsURL <- map["gists_url"]
75 | starredURL <- map["starred_url"]
76 | subscriptionsURL <- map["subscriptions_url"]
77 | organizationsURL <- map["organizations_url"]
78 | reposURL <- map["repos_url"]
79 | eventsURL <- map["events_url"]
80 | receivedEventsURL <- map["received_events_url"]
81 | type <- map["type"]
82 | siteAdmin <- map["site_admin"]
83 | name <- map["name"]
84 | company <- map["company"]
85 | blog <- map["blog"]
86 | location <- map["location"]
87 | email <- map["email"]
88 | hireable <- map["hireable"]
89 | bio <- map["bio"]
90 | publicRepos <- map["public_repos"]
91 | publicGists <- map["public_gists"]
92 | followers <- map["followers"]
93 | following <- map["following"]
94 | createdAt <- (map["created_at"], DateTransform())
95 | updatedAt <- map["updated_at"]
96 | test <- map["test"]
97 | }
98 |
99 | }
--------------------------------------------------------------------------------
/Benchmark/ModelBenchmark/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/Benchmark/ModelBenchmark/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleLocalizations
14 |
15 | en
16 | zh
17 | zh_TW
18 | fr
19 | de
20 | it
21 | ja
22 | ko
23 |
24 | CFBundleName
25 | $(PRODUCT_NAME)
26 | CFBundlePackageType
27 | APPL
28 | CFBundleShortVersionString
29 | 1.0
30 | CFBundleSignature
31 | ????
32 | CFBundleVersion
33 | 1
34 | LSRequiresIPhoneOS
35 |
36 | UILaunchStoryboardName
37 | LaunchScreen
38 | UIMainStoryboardFile
39 | Main
40 | UIRequiredDeviceCapabilities
41 |
42 | armv7
43 |
44 | UISupportedInterfaceOrientations
45 |
46 | UIInterfaceOrientationPortrait
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/Benchmark/ModelBenchmark/ModelBenchmark-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | //
2 | // Use this file to import your target's public headers that you would like to expose to Swift.
3 | //
4 |
5 |
--------------------------------------------------------------------------------
/Benchmark/ModelBenchmark/Test.h:
--------------------------------------------------------------------------------
1 | //
2 | // Test.h
3 | // ModelBenchmark
4 | //
5 | // Created by WHC on 16/11/30.
6 | // Copyright © 2016年 ibireme. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "NSObject+WHC_Model.h"
11 |
12 | @interface Status :NSObject
13 | @property (nonatomic , copy) NSString * msg;
14 | @property (nonatomic , assign) NSInteger code;
15 |
16 | @end
17 |
18 | @interface Test :NSObject
19 | @property (nonatomic , strong) Status * status;
20 | @property (nonatomic , strong) NSArray * data;
21 | @property (nonatomic , copy) NSString * token;
22 |
23 | @end
24 |
25 |
--------------------------------------------------------------------------------
/Benchmark/ModelBenchmark/Test.m:
--------------------------------------------------------------------------------
1 | //
2 | // Test.m
3 | // ModelBenchmark
4 | //
5 | // Created by WHC on 16/11/30.
6 | // Copyright © 2016年 ibireme. All rights reserved.
7 | //
8 |
9 | #import "Test.h"
10 |
11 | @implementation Test
12 |
13 | @end
14 | @implementation Status
15 | - (id)initWithCoder:(NSCoder *)decoder {
16 | if (self = [super init]) {
17 | [self whc_Decode:decoder];
18 | }
19 | return self;
20 | }
21 |
22 | - (void)encodeWithCoder:(NSCoder *)encoder {
23 | [self whc_Encode:encoder];
24 | }
25 |
26 | - (id)copyWithZone:(NSZone *)zone {
27 | return [self whc_Copy];
28 | }
29 |
30 | @end
31 |
32 |
--------------------------------------------------------------------------------
/Benchmark/ModelBenchmark/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // ModelBenchmark
4 | //
5 | // Created by ibireme on 15/9/18.
6 | // Copyright (c) 2015 ibireme. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/Benchmark/ModelBenchmark/WHC_Model/NSObject+WHC_Model.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+WHC_Model.h
3 | // WHC_Model
4 | //
5 | // Created by WHC on 16/7/13.
6 | // Copyright © 2016年 whc. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 | // VERSION:(1.2.0)
27 | #import
28 |
29 | ///模型对象归档解归档实现
30 | #define WHC_CodingImplementation \
31 | - (id)initWithCoder:(NSCoder *)decoder \
32 | { \
33 | if (self = [super init]) { \
34 | [self whc_Decode:decoder]; \
35 | } \
36 | return self; \
37 | } \
38 | \
39 | - (void)encodeWithCoder:(NSCoder *)encoder \
40 | { \
41 | [self whc_Encode:encoder]; \
42 | }\
43 | - (id)copyWithZone:(NSZone *)zone { return [self whc_Copy]; }
44 |
45 | @protocol WHC_ModelKeyValue
46 | @optional
47 | /// 模型类可自定义属性名称
48 | + (NSDictionary *)whc_ModelReplacePropertyMapper;
49 | /// 模型数组/字典元素可自定义类
50 | + (NSDictionary *)whc_ModelReplaceContainerElementClassMapper;
51 | /// 模型类可自定义属性类型
52 | + (NSDictionary *)whc_ModelReplacePropertyClassMapper;
53 |
54 | @end
55 |
56 | @interface NSObject (WHC_Model)
57 |
58 | #pragma mark - json转模型对象 Api -
59 |
60 | /** 说明:把json解析为模型对象
61 | *@param json :json数据对象
62 | *@return 模型对象
63 | */
64 | + (id)whc_ModelWithJson:(id)json;
65 |
66 | /** 说明:把json解析为模型对象
67 | *@param json :json数据对象
68 | *@param keyPath :json key的路径
69 | *@return 模型对象
70 | */
71 |
72 | + (id)whc_ModelWithJson:(id)json keyPath:(NSString *)keyPath;
73 |
74 |
75 | #pragma mark - 模型对象转json Api -
76 |
77 | /** 说明:把模型对象转换为字典
78 | *@return 字典对象
79 | */
80 |
81 | - (NSDictionary *)whc_Dictionary;
82 |
83 | /** 说明:把模型对象转换为json字符串
84 | *@return json字符串
85 | */
86 |
87 | - (NSString *)whc_Json;
88 |
89 | #pragma mark - 模型对象序列化 Api -
90 |
91 | /// 复制模型对象
92 | - (id)whc_Copy;
93 |
94 | /// 序列化模型对象
95 | - (void)whc_Encode:(NSCoder *)aCoder;
96 |
97 | /// 反序列化模型对象
98 | - (void)whc_Decode:(NSCoder *)aDecoder;
99 | @end
100 |
--------------------------------------------------------------------------------
/Benchmark/ModelBenchmark/YYModel/YYModel.h:
--------------------------------------------------------------------------------
1 | //
2 | // YYModel.h
3 | // YYModel
4 | //
5 | // Created by ibireme on 15/5/10.
6 | // Copyright (c) 2015 ibireme.
7 | //
8 | // This source code is licensed under the MIT-style license found in the
9 | // LICENSE file in the root directory of this source tree.
10 | //
11 |
12 | #import
13 |
14 | #if __has_include()
15 | FOUNDATION_EXPORT double YYModelVersionNumber;
16 | FOUNDATION_EXPORT const unsigned char YYModelVersionString[];
17 | #import
18 | #import
19 | #else
20 | #import "NSObject+YYModel.h"
21 | #import "YYClassInfo.h"
22 | #endif
23 |
--------------------------------------------------------------------------------
/Benchmark/ModelBenchmark/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // ModelBenchmark
4 | //
5 | // Created by ibireme on 15/9/18.
6 | // Copyright (c) 2015 ibireme. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Benchmark/ModelBenchmark/user.json:
--------------------------------------------------------------------------------
1 | {
2 | "login": "facebook",
3 | "id": 69631,
4 | "avatar_url": "https://avatars.githubusercontent.com/u/69631?v=3",
5 | "gravatar_id": "",
6 | "url": "https://api.github.com/users/facebook",
7 | "html_url": "https://github.com/facebook",
8 | "followers_url": "https://api.github.com/users/facebook/followers",
9 | "following_url": "https://api.github.com/users/facebook/following{/other_user}",
10 | "gists_url": "https://api.github.com/users/facebook/gists{/gist_id}",
11 | "starred_url": "https://api.github.com/users/facebook/starred{/owner}{/repo}",
12 | "subscriptions_url": "https://api.github.com/users/facebook/subscriptions",
13 | "organizations_url": "https://api.github.com/users/facebook/orgs",
14 | "repos_url": "https://api.github.com/users/facebook/repos",
15 | "events_url": "https://api.github.com/users/facebook/events{/privacy}",
16 | "received_events_url": "https://api.github.com/users/facebook/received_events",
17 | "type": "Organization",
18 | "site_admin": false,
19 | "name": "Facebook",
20 | "company": null,
21 | "blog": "https://code.facebook.com/projects/",
22 | "location": "Menlo Park, California",
23 | "email": null,
24 | "hireable": null,
25 | "bio": "We work hard to contribute our work back to the web, mobile, big data, & infrastructure communities. NB: members must have two-factor auth.",
26 | "public_repos": 147,
27 | "public_gists": 12,
28 | "followers": 0,
29 | "following": 0
30 | }
31 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Core/Assignment Policy/FEMAssignmentPolicy.h:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import
4 |
5 | @class FEMRelationshipAssignmentContext;
6 |
7 | typedef __nullable id (^FEMAssignmentPolicy)(FEMRelationshipAssignmentContext * __nonnull context);
8 |
9 | OBJC_EXTERN __nonnull FEMAssignmentPolicy FEMAssignmentPolicyAssign;
10 |
11 | OBJC_EXTERN __nonnull FEMAssignmentPolicy FEMAssignmentPolicyObjectMerge;
12 | OBJC_EXTERN __nonnull FEMAssignmentPolicy FEMAssignmentPolicyCollectionMerge;
13 |
14 | OBJC_EXTERN __nonnull FEMAssignmentPolicy FEMAssignmentPolicyObjectReplace;
15 | OBJC_EXTERN __nonnull FEMAssignmentPolicy FEMAssignmentPolicyCollectionReplace;
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Core/Assignment Policy/FEMAssignmentPolicy.m:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import "FEMAssignmentPolicy.h"
4 |
5 | #import "FEMRelationshipAssignmentContext.h"
6 | #import "FEMExcludableCollection.h"
7 | #import "FEMMergeableCollection.h"
8 |
9 | FEMAssignmentPolicy FEMAssignmentPolicyAssign = ^id(FEMRelationshipAssignmentContext * context) {
10 | return context.targetRelationshipValue;
11 | };
12 |
13 | FEMAssignmentPolicy FEMAssignmentPolicyObjectMerge = ^id(FEMRelationshipAssignmentContext *context) {
14 | return context.targetRelationshipValue ?: context.sourceRelationshipValue;
15 | };
16 |
17 | FEMAssignmentPolicy FEMAssignmentPolicyCollectionMerge = ^id(FEMRelationshipAssignmentContext *context) {
18 | if (!context.targetRelationshipValue) return context.sourceRelationshipValue;
19 |
20 | NSCAssert(
21 | [context.targetRelationshipValue conformsToProtocol:@protocol(FEMMergeableCollection)],
22 | @"Collection %@ should support protocol %@",
23 | NSStringFromClass([context.targetRelationshipValue class]),
24 | NSStringFromProtocol(@protocol(FEMMergeableCollection))
25 | );
26 |
27 | return [context.targetRelationshipValue collectionByMergingObjects:context.sourceRelationshipValue];
28 | };
29 |
30 | FEMAssignmentPolicy FEMAssignmentPolicyObjectReplace = ^id(FEMRelationshipAssignmentContext *context) {
31 | if (context.sourceRelationshipValue && ![context.sourceRelationshipValue isEqual:context.targetRelationshipValue]) {
32 | [context deleteRelationshipObject:context.sourceRelationshipValue];
33 | }
34 |
35 | return context.targetRelationshipValue;
36 | };
37 |
38 | FEMAssignmentPolicy FEMAssignmentPolicyCollectionReplace = ^id(FEMRelationshipAssignmentContext *context) {
39 | if (!context.sourceRelationshipValue) return context.targetRelationshipValue;
40 |
41 | if (context.targetRelationshipValue) {
42 | NSCAssert(
43 | [context.sourceRelationshipValue conformsToProtocol:@protocol(FEMExcludableCollection)],
44 | @"Collection %@ should support protocol %@",
45 | NSStringFromClass([context.targetRelationshipValue class]),
46 | NSStringFromProtocol(@protocol(FEMExcludableCollection))
47 | );
48 |
49 | id objectsToDelete = [(id ) context.sourceRelationshipValue collectionByExcludingObjects:context.targetRelationshipValue];
50 | for (id object in objectsToDelete) {
51 | [context deleteRelationshipObject:object];
52 | }
53 | } else {
54 | for (id object in context.sourceRelationshipValue) {
55 | [context deleteRelationshipObject:object];
56 | }
57 | }
58 |
59 | return context.targetRelationshipValue;
60 | };
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Core/Assignment Policy/FEMRelationshipAssignmentContext+Internal.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by zen on 13/05/15.
3 | // Copyright (c) 2015 Yalantis. All rights reserved.
4 | //
5 |
6 | #import
7 |
8 | #import "FEMRelationshipAssignmentContext.h"
9 |
10 | @interface FEMRelationshipAssignmentContext (Internal)
11 |
12 | @property (nonatomic, strong) id destinationObject;
13 | @property (nonatomic, strong) FEMRelationship *relationship;
14 |
15 | @property (nonatomic, strong) id sourceRelationshipValue;
16 | @property (nonatomic, strong) id targetRelationshipValue;
17 |
18 | @end
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Core/Assignment Policy/FEMRelationshipAssignmentContext.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by zen on 13/05/15.
3 | // Copyright (c) 2015 Yalantis. All rights reserved.
4 | //
5 |
6 | #import
7 |
8 | @class FEMRelationship, FEMObjectStore, FEMRelationshipAssignmentContext;
9 |
10 | @protocol FEMRelationshipAssignmentContextDelegate
11 | @required
12 |
13 | - (void)assignmentContext:(nonnull FEMRelationshipAssignmentContext *)context deletedObject:(nonnull id)object;
14 |
15 | @end
16 |
17 |
18 | @interface FEMRelationshipAssignmentContext: NSObject
19 |
20 | @property (nonatomic, unsafe_unretained, readonly, nonnull) FEMObjectStore *store;
21 | - (nonnull instancetype)initWithStore:(nonnull FEMObjectStore *)store;
22 |
23 | @property (nonatomic, strong, readonly, nonnull) id destinationObject;
24 | @property (nonatomic, strong, readonly, nonnull) FEMRelationship *relationship;
25 |
26 | @property (nonatomic, strong, readonly, nullable) id sourceRelationshipValue;
27 | @property (nonatomic, strong, readonly, nullable) id targetRelationshipValue;
28 |
29 | - (void)deleteRelationshipObject:(nonnull id)object;
30 |
31 | @end
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Core/Assignment Policy/FEMRelationshipAssignmentContext.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by zen on 13/05/15.
3 | // Copyright (c) 2015 Yalantis. All rights reserved.
4 | //
5 |
6 | #import "FEMRelationshipAssignmentContext.h"
7 | #import "FEMRelationshipAssignmentContext+Internal.h"
8 |
9 | #import "FEMRelationship.h"
10 | #import "FEMObjectStore.h"
11 |
12 | @interface FEMRelationshipAssignmentContext ()
13 |
14 | @property (nonatomic, strong) id destinationObject;
15 | @property (nonatomic, strong) FEMRelationship *relationship;
16 |
17 | @property (nonatomic, strong) id sourceRelationshipValue;
18 | @property (nonatomic, strong) id targetRelationshipValue;
19 |
20 | @property (nonatomic, unsafe_unretained) id delegate;
21 |
22 | @end
23 |
24 | @implementation FEMRelationshipAssignmentContext
25 |
26 | - (instancetype)initWithStore:(FEMObjectStore *)store {
27 | self = [super init];
28 | if (self) {
29 | _store = store;
30 | self.delegate = store;
31 | }
32 |
33 | return self;
34 | }
35 |
36 | - (void)deleteRelationshipObject:(id)object {
37 | [self.delegate assignmentContext:self deletedObject:object];
38 | }
39 |
40 | @end
41 |
42 | @implementation FEMRelationshipAssignmentContext (Internal)
43 |
44 | @dynamic destinationObject;
45 | @dynamic relationship;
46 | @dynamic sourceRelationshipValue;
47 | @dynamic targetRelationshipValue;
48 |
49 | @end
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Core/Cache/FEMManagedObjectCache.h:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import
4 |
5 | @class FEMMapping, NSManagedObjectContext;
6 |
7 | @interface FEMManagedObjectCache : NSObject
8 |
9 | @property (nonatomic, strong, readonly) NSManagedObjectContext *context;
10 |
11 | - (instancetype)initWithMapping:(FEMMapping *)mapping representation:(id)representation context:(NSManagedObjectContext *)context;
12 |
13 | - (id)existingObjectForRepresentation:(id)representation mapping:(FEMMapping *)mapping;
14 | - (id)existingObjectForPrimaryKey:(id)primaryKey mapping:(FEMMapping *)mapping;
15 |
16 | - (void)addExistingObject:(id)object mapping:(FEMMapping *)mapping;
17 | - (NSDictionary *)existingObjectsForMapping:(FEMMapping *)mapping;
18 |
19 | @end
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Core/Cache/FEMManagedObjectCache.m:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import "FEMManagedObjectCache.h"
4 |
5 | #import
6 |
7 | #import "FEMMapping.h"
8 | #import "FEMRepresentationUtility.h"
9 |
10 | @implementation FEMManagedObjectCache {
11 | NSManagedObjectContext *_context;
12 |
13 | NSDictionary *_lookupKeysMap;
14 | NSMutableDictionary *_lookupObjectsMap;
15 | }
16 |
17 | #pragma mark - Init
18 |
19 |
20 | - (instancetype)initWithMapping:(FEMMapping *)mapping representation:(id)representation context:(NSManagedObjectContext *)context {
21 | NSParameterAssert(mapping);
22 | NSParameterAssert(representation);
23 | NSParameterAssert(context);
24 |
25 | self = [self init];
26 | if (self) {
27 | _context = context;
28 |
29 | _lookupKeysMap = FEMRepresentationCollectPresentedPrimaryKeys(representation, mapping);
30 | _lookupObjectsMap = [NSMutableDictionary new];
31 | }
32 |
33 | return self;
34 | }
35 |
36 | #pragma mark - Inspection
37 |
38 | - (NSMutableDictionary *)fetchExistingObjectsForMapping:(FEMMapping *)mapping {
39 | NSSet *lookupValues = _lookupKeysMap[mapping.entityName];
40 | if (lookupValues.count == 0) return [NSMutableDictionary dictionary];
41 |
42 | NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:mapping.entityName];
43 | NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K IN %@", mapping.primaryKey, lookupValues];
44 | [fetchRequest setPredicate:predicate];
45 | [fetchRequest setFetchLimit:lookupValues.count];
46 |
47 | NSMutableDictionary *output = [NSMutableDictionary new];
48 | NSArray *existingObjects = [_context executeFetchRequest:fetchRequest error:NULL];
49 | for (NSManagedObject *object in existingObjects) {
50 | output[[object valueForKey:mapping.primaryKey]] = object;
51 | }
52 |
53 | return output;
54 | }
55 |
56 | - (NSMutableDictionary *)cachedObjectsForMapping:(FEMMapping *)mapping {
57 | NSMutableDictionary *entityObjectsMap = _lookupObjectsMap[mapping.entityName];
58 | if (!entityObjectsMap) {
59 | entityObjectsMap = [self fetchExistingObjectsForMapping:mapping];
60 | _lookupObjectsMap[mapping.entityName] = entityObjectsMap;
61 | }
62 |
63 | return entityObjectsMap;
64 | }
65 |
66 | - (id)existingObjectForRepresentation:(id)representation mapping:(FEMMapping *)mapping {
67 | NSDictionary *entityObjectsMap = [self cachedObjectsForMapping:mapping];
68 |
69 | id primaryKeyValue = FEMRepresentationValueForAttribute(representation, mapping.primaryKeyAttribute);
70 | if (primaryKeyValue == nil || primaryKeyValue == NSNull.null) return nil;
71 |
72 | return entityObjectsMap[primaryKeyValue];
73 | }
74 |
75 | - (id)existingObjectForPrimaryKey:(id)primaryKey mapping:(FEMMapping *)mapping {
76 | NSDictionary *entityObjectsMap = [self cachedObjectsForMapping:mapping];
77 |
78 | return entityObjectsMap[primaryKey];
79 | }
80 |
81 | - (void)addExistingObject:(id)object mapping:(FEMMapping *)mapping {
82 | NSParameterAssert(mapping.primaryKey);
83 | NSParameterAssert(object);
84 |
85 | id primaryKeyValue = [object valueForKey:mapping.primaryKey];
86 | NSAssert(primaryKeyValue, @"No value for key (%@) on object (%@) found", mapping.primaryKey, object);
87 |
88 | NSMutableDictionary *entityObjectsMap = [self cachedObjectsForMapping:mapping];
89 | entityObjectsMap[primaryKeyValue] = object;
90 | }
91 |
92 | - (NSDictionary *)existingObjectsForMapping:(FEMMapping *)mapping {
93 | return [[self cachedObjectsForMapping:mapping] copy];
94 | }
95 |
96 | @end
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Core/Deserializer/FEMDeserializer.h:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import
4 | #import "FEMManagedObjectMapping.h"
5 |
6 | @class FEMObjectStore, FEMMapping, NSManagedObject, NSFetchRequest, NSManagedObjectContext;
7 | @class FEMDeserializer;
8 |
9 | @protocol FEMDeserializerDelegate
10 |
11 | @optional
12 | - (void)deserializer:(nonnull FEMDeserializer *)deserializer willMapObjectFromRepresentation:(nonnull id)representation mapping:(nonnull FEMMapping *)mapping;
13 | - (void)deserializer:(nonnull FEMDeserializer *)deserializer didMapObject:(nonnull id)object fromRepresentation:(nonnull id)representation mapping:(nonnull FEMMapping *)mapping;
14 |
15 | - (void)deserializer:(nonnull FEMDeserializer *)deserializer willMapCollectionFromRepresentation:(nonnull NSArray *)representation mapping:(nonnull FEMMapping *)mapping;
16 | - (void)deserializer:(nonnull FEMDeserializer *)deserializer didMapCollection:(nonnull NSArray *)collection fromRepresentation:(nonnull NSArray *)representation mapping:(nonnull FEMMapping *)mapping;
17 |
18 | @end
19 |
20 | @interface FEMDeserializer : NSObject
21 |
22 | @property (nonatomic, strong, readonly, nonnull) FEMObjectStore *store;
23 | - (nonnull instancetype)initWithStore:(nonnull FEMObjectStore *)store NS_DESIGNATED_INITIALIZER;
24 |
25 | - (nonnull instancetype)init;
26 | - (nonnull instancetype)initWithContext:(nonnull NSManagedObjectContext *)context;
27 |
28 | @property (nonatomic, unsafe_unretained, nullable) id delegate;
29 |
30 | - (nonnull id)objectFromRepresentation:(nonnull NSDictionary *)representation mapping:(nonnull FEMMapping *)mapping;
31 | - (nonnull id)fillObject:(nonnull id)object fromRepresentation:(nonnull NSDictionary *)representation mapping:(nonnull FEMMapping *)mapping;
32 | - (nonnull NSArray *)collectionFromRepresentation:(nonnull NSArray *)representation mapping:(nonnull FEMMapping *)mapping;
33 |
34 | @end
35 |
36 | @interface FEMDeserializer (Extension)
37 |
38 | + (nonnull id)objectFromRepresentation:(nonnull NSDictionary *)representation mapping:(nonnull FEMMapping *)mapping context:(nonnull NSManagedObjectContext *)context;
39 | + (nonnull id)objectFromRepresentation:(nonnull NSDictionary *)representation mapping:(nonnull FEMMapping *)mapping;
40 |
41 | + (nonnull id)fillObject:(nonnull id)object fromRepresentation:(nonnull NSDictionary *)representation mapping:(nonnull FEMMapping *)mapping;
42 |
43 | + (nonnull NSArray *)collectionFromRepresentation:(nonnull NSArray *)representation mapping:(nonnull FEMMapping *)mapping context:(nonnull NSManagedObjectContext *)context;
44 | + (nonnull NSArray *)collectionFromRepresentation:(nonnull NSArray *)representation mapping:(nonnull FEMMapping *)mapping;
45 |
46 | @end
47 |
48 |
49 | @interface FEMDeserializer (FEMObjectDeserializer_Deprecated)
50 |
51 | + (nonnull id)deserializeObjectExternalRepresentation:(nonnull NSDictionary *)externalRepresentation usingMapping:(nonnull FEMMapping *)mapping __attribute__((deprecated("Use +[FEMDeserializer objectFromRepresentation:mapping:] instead")));
52 | + (nonnull id)fillObject:(nonnull id)object fromExternalRepresentation:(nonnull NSDictionary *)externalRepresentation usingMapping:(nonnull FEMMapping *)mapping __attribute__((deprecated("Use +[FEMDeserializer fillObject:fromRepresentation:mapping:] instead")));
53 | + (nonnull NSArray *)deserializeCollectionExternalRepresentation:(nonnull NSArray *)externalRepresentation usingMapping:(nonnull FEMMapping *)mapping __attribute__((deprecated("Use +[FEMDeserializer collectionFromRepresentation:mapping:] instead")));
54 |
55 | @end
56 |
57 | @interface FEMDeserializer (FEMManagedObjectDeserializer_Deprecated)
58 |
59 | + (nonnull id)deserializeObjectExternalRepresentation:(nonnull NSDictionary *)externalRepresentation usingMapping:(nonnull FEMMapping *)mapping context:(nonnull NSManagedObjectContext *)context __attribute__((deprecated("Use +[FEMDeserializer objectFromRepresentation:mapping:context:] instead")));
60 | + (nonnull NSArray *)deserializeCollectionExternalRepresentation:(nonnull NSArray *)externalRepresentation usingMapping:(nonnull FEMMapping *)mapping context:(nonnull NSManagedObjectContext *)context __attribute__((deprecated("Use +[FEMDeserializer collectionFromRepresentation:mapping:context:] instead")));
61 | + (nonnull NSArray *)synchronizeCollectionExternalRepresentation:(nonnull NSArray *)externalRepresentation usingMapping:(nonnull FEMMapping *)mapping predicate:(nonnull NSPredicate *)predicate context:(nonnull NSManagedObjectContext *)context __attribute__((unavailable));
62 |
63 | @end
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Core/Deserializer/FEMManagedObjectDeserializer.h:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import "FEMDeserializer.h"
4 |
5 | @compatibility_alias FEMManagedObjectDeserializer FEMDeserializer;
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Core/Deserializer/FEMObjectDeserializer.h:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import "FEMDeserializer.h"
4 |
5 | @compatibility_alias FEMObjectDeserializer FEMDeserializer;
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Core/Mapping/FEMAttribute.h:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import
4 |
5 | #import "FEMTypes.h"
6 | #import "FEMProperty.h"
7 |
8 | @interface FEMAttribute : NSObject
9 |
10 | - (nullable id)mapValue:(nullable id)value;
11 | - (nullable id)reverseMapValue:(nullable id)value;
12 |
13 | - (nonnull instancetype)initWithProperty:(nonnull NSString *)property keyPath:(nullable NSString *)keyPath map:(nullable FEMMapBlock)map reverseMap:(nullable FEMMapBlock)reverseMap;
14 | + (nonnull instancetype)mappingOfProperty:(nonnull NSString *)property toKeyPath:(nullable NSString *)keyPath map:(nullable FEMMapBlock)map reverseMap:(nullable FEMMapBlock)reverseMap;
15 |
16 | @end
17 |
18 | @interface FEMAttribute (Shortcut)
19 |
20 | /**
21 | * same as +[FEMAttribute mappingOfProperty:property toKeyPath:property];
22 | */
23 | + (nonnull instancetype)mappingOfProperty:(nonnull NSString *)property;
24 |
25 | /**
26 | * same as +[FEMAttribute mappingOfProperty:property toKeyPath:nil map:NULL];
27 | */
28 | + (nonnull instancetype)mappingOfProperty:(nonnull NSString *)property toKeyPath:(nonnull NSString *)keyPath;
29 |
30 | /**
31 | * same as +[FEMAttribute mappingOfProperty:property toKeyPath:nil map:map];
32 | */
33 | + (nonnull instancetype)mappingOfProperty:(nonnull NSString *)property map:(nonnull FEMMapBlock)map;
34 |
35 | + (nonnull instancetype)mappingOfProperty:(nonnull NSString *)property reverseMap:(nonnull FEMMapBlock)reverseMap;
36 |
37 | /**
38 | * same as +[FEMAttribute mappingOfProperty:property toKeyPath:nil map:NULL reverseMap:NULL];
39 | */
40 | + (nonnull instancetype)mappingOfProperty:(nonnull NSString *)property toKeyPath:(nonnull NSString *)keyPath map:(nonnull FEMMapBlock)map;
41 |
42 | /**
43 | * create mapping object, based on NSDateFormatter.
44 | * NSDateFormatter instance uses en_US_POSIX locale and UTC Timezone
45 | */
46 | + (nonnull instancetype)mappingOfProperty:(nonnull NSString *)property toKeyPath:(nullable NSString *)keyPath dateFormat:(nonnull NSString *)dateFormat;
47 |
48 | /**
49 | * property represented by NSURL, value at keyPath - NSString
50 | */
51 | + (nonnull instancetype)mappingOfURLProperty:(nonnull NSString *)property toKeyPath:(nullable NSString *)keyPath;
52 |
53 | @end
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Core/Mapping/FEMAttribute.m:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import "FEMAttribute.h"
4 |
5 | @implementation FEMAttribute {
6 | FEMMapBlock _map;
7 | FEMMapBlock _reverseMap;
8 | }
9 |
10 | @synthesize property = _property;
11 | @synthesize keyPath = _keyPath;
12 |
13 | #pragma mark - Init
14 |
15 | - (id)initWithProperty:(NSString *)property keyPath:(NSString *)keyPath map:(FEMMapBlock)map reverseMap:(FEMMapBlock)reverseMap {
16 | NSParameterAssert(property.length > 0);
17 |
18 | self = [super init];
19 | if (self) {
20 | self.property = property;
21 | self.keyPath = keyPath;
22 |
23 | FEMMapBlock passthroughMap = ^(id value) {
24 | return value;
25 | };
26 |
27 | _map = map ?: passthroughMap;
28 | _reverseMap = reverseMap ?: passthroughMap;
29 | }
30 |
31 | return self;
32 | }
33 |
34 | + (instancetype)mappingOfProperty:(NSString *)property toKeyPath:(NSString *)keyPath map:(FEMMapBlock)map reverseMap:(FEMMapBlock)reverseMap {
35 | return [[self alloc] initWithProperty:property keyPath:keyPath map:map reverseMap:reverseMap];
36 | }
37 |
38 | #pragma mark - Description
39 |
40 | - (NSString *)description {
41 | return [NSString stringWithFormat:
42 | @"<%@ %p> property:%@ keyPath:%@",
43 | NSStringFromClass(self.class),
44 | (__bridge void *) self,
45 | self.property,
46 | self.keyPath
47 | ];
48 | }
49 |
50 | #pragma mark - Mapping
51 |
52 | - (id)mapValue:(id)value {
53 | return _map(value);
54 | }
55 |
56 | - (id)reverseMapValue:(id)value {
57 | return _reverseMap(value);
58 | }
59 |
60 | @end
61 |
62 | @implementation FEMAttribute (Shortcut)
63 |
64 | + (instancetype)mappingOfProperty:(NSString *)property toKeyPath:(NSString *)keyPath map:(FEMMapBlock)map {
65 | return [self mappingOfProperty:property toKeyPath:keyPath map:map reverseMap:NULL];
66 | }
67 |
68 | + (instancetype)mappingOfProperty:(NSString *)property toKeyPath:(NSString *)keyPath {
69 | return [self mappingOfProperty:property toKeyPath:keyPath map:NULL reverseMap:NULL];
70 | }
71 |
72 | + (instancetype)mappingOfProperty:(NSString *)property {
73 | return [self mappingOfProperty:property toKeyPath:nil map:NULL reverseMap:NULL];
74 | }
75 |
76 | + (instancetype)mappingOfProperty:(NSString *)property map:(FEMMapBlock)map {
77 | return [self mappingOfProperty:property toKeyPath:nil map:map reverseMap:NULL];
78 | }
79 |
80 | + (nonnull instancetype)mappingOfProperty:(nonnull NSString *)property reverseMap:(nonnull FEMMapBlock)reverseMap {
81 | return [self mappingOfProperty:property toKeyPath:nil map:NULL reverseMap:reverseMap];
82 | }
83 |
84 | + (instancetype)mappingOfProperty:(NSString *)property toKeyPath:(NSString *)keyPath dateFormat:(NSString *)dateFormat {
85 | NSDateFormatter *formatter = [NSDateFormatter new];
86 | [formatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
87 | [formatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
88 | [formatter setDateFormat:dateFormat];
89 |
90 | return [self mappingOfProperty:property toKeyPath:keyPath map:^id(id value) {
91 | return [value isKindOfClass:[NSString class]] ? [formatter dateFromString:value] : NSNull.null;
92 | } reverseMap:^id(id value) {
93 | return [formatter stringFromDate:value];
94 | }];
95 | }
96 |
97 | + (instancetype)mappingOfURLProperty:(NSString *)property toKeyPath:(NSString *)keyPath {
98 | return [FEMAttribute mappingOfProperty:property toKeyPath:keyPath map:^id(id value) {
99 | return [value isKindOfClass:NSString.class] ? [NSURL URLWithString:value] : NSNull.null;
100 | } reverseMap:^id(NSURL *value) {
101 | return [value absoluteString];
102 | }];
103 | }
104 |
105 | @end
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Core/Mapping/FEMManagedObjectMapping.h:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import
4 |
5 | #import "FEMMapping.h"
6 |
7 | @compatibility_alias FEMManagedObjectMapping FEMMapping;
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Core/Mapping/FEMMapping.h:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import
4 |
5 | #import "FEMAttribute.h"
6 | #import "FEMRelationship.h"
7 |
8 | @interface FEMMapping : NSObject {
9 | @protected
10 | NSMutableDictionary *_attributeMap;
11 | NSMutableDictionary *_relationshipMap;
12 | }
13 |
14 | - (nonnull instancetype)init __attribute__((unavailable("use -[FEMMapping initWithObjectClass:] or -[FEMMapping initWithEntityName:] insted")));
15 | + (nonnull instancetype)new __attribute__((unavailable("use -[FEMMapping initWithObjectClass:] or -[FEMMapping initWithEntityName:] insted")));
16 | - (nonnull instancetype)initWithRootPath:(nullable NSString *)rootPath __attribute__((unavailable("use -[FEMMapping initWithObjectClass:] or -[FEMMapping initWithEntityName:] insted")));
17 |
18 | - (nonnull instancetype)initWithObjectClass:(nonnull Class)objectClass NS_DESIGNATED_INITIALIZER;
19 | - (nonnull instancetype)initWithObjectClass:(nonnull Class)objectClass rootPath:(nullable NSString *)rootPath;
20 |
21 | - (nonnull instancetype)initWithEntityName:(nonnull NSString *)entityName NS_DESIGNATED_INITIALIZER;
22 | - (nonnull instancetype)initWithEntityName:(nonnull NSString *)entityName rootPath:(nullable NSString *)rootPath;
23 |
24 | @property (nonatomic, readonly, nullable) Class objectClass;
25 | @property (nonatomic, copy, readonly, nullable) NSString *entityName;
26 |
27 | @property (nonatomic, copy, nullable) NSString *rootPath;
28 |
29 | @property (nonatomic, copy, nullable) NSString *primaryKey;
30 | @property (nonatomic, strong, readonly, nullable) FEMAttribute *primaryKeyAttribute;
31 |
32 | @property (nonatomic, strong, readonly, nonnull) NSArray *attributes;
33 | - (void)addAttribute:(nonnull FEMAttribute *)attribute;
34 | - (nullable FEMAttribute *)attributeForProperty:(nonnull NSString *)property;
35 |
36 | @property (nonatomic, strong, readonly, nonnull) NSArray *relationships;
37 | - (void)addRelationship:(nonnull FEMRelationship *)relationship;
38 | - (nullable FEMRelationship *)relationshipForProperty:(nonnull NSString *)property;
39 |
40 | @end
41 |
42 | @interface FEMMapping (Shortcut)
43 |
44 | - (void)addAttributesFromArray:(nonnull NSArray *)attributes;
45 | - (void)addAttributesFromDictionary:(nonnull NSDictionary *)attributesToKeyPath;
46 | - (void)addAttributeWithProperty:(nonnull NSString *)property keyPath:(nullable NSString *)keyPath;
47 |
48 | - (void)addRelationshipMapping:(nonnull FEMMapping *)mapping forProperty:(nonnull NSString *)property keyPath:(nullable NSString *)keyPath;
49 | - (void)addToManyRelationshipMapping:(nonnull FEMMapping *)mapping forProperty:(nonnull NSString *)property keyPath:(nullable NSString *)keyPath;
50 |
51 | @end
52 |
53 | @interface FEMMapping (FEMObjectMapping_Deprecated)
54 |
55 | + (nonnull FEMMapping *)mappingForClass:(nonnull Class)objectClass configuration:(nonnull void (^)(FEMMapping * __nonnull mapping))configuration __attribute__((deprecated("Use -[FEMMapping initWithObjectClass:] instead")));
56 | + (nonnull FEMMapping *)mappingForClass:(nonnull Class)objectClass rootPath:(nullable NSString *)rootPath configuration:(nonnull void (^)(FEMMapping * __nonnull mapping))configuration __attribute__((deprecated("Use -[FEMMapping initWithObjectClass:rootPath:] instead")));
57 |
58 | @end
59 |
60 |
61 | @interface FEMMapping (FEMManagedObjectMapping_Deprecated)
62 |
63 | + (nonnull FEMMapping *)mappingForEntityName:(nonnull NSString *)entityName __attribute__((deprecated("Use -[FEMMapping initWithEntityName:] instead")));
64 | + (nonnull FEMMapping *)mappingForEntityName:(nonnull NSString *)entityName configuration:(nullable void (^)(FEMMapping * __nonnull sender))configuration __attribute__((deprecated("Use -[FEMMapping initWithEntityName:] instead")));
65 | + (nonnull FEMMapping *)mappingForEntityName:(nonnull NSString *)entityName rootPath:(nullable NSString *)rootPath configuration:(nullable void (^)(FEMMapping * __nonnull sender))configuration __attribute__((deprecated("Use -[FEMMapping initWithEntityName:rootPath:] instead")));
66 |
67 | @end
68 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Core/Mapping/FEMObjectMapping.h:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import "FEMMapping.h"
4 |
5 | @compatibility_alias FEMObjectMapping FEMMapping;
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Core/Mapping/FEMProperty.h:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import
4 |
5 | @protocol FEMProperty
6 |
7 | @property (nonatomic, copy, nonnull) NSString *property;
8 | @property (nonatomic, copy, nullable) NSString *keyPath;
9 |
10 | @end
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Core/Mapping/FEMRelationship.h:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import
4 |
5 | #import "FEMAssignmentPolicy.h"
6 | #import "FEMProperty.h"
7 |
8 | NS_ASSUME_NONNULL_BEGIN
9 |
10 | @class FEMMapping;
11 |
12 | @interface FEMRelationship : NSObject
13 |
14 | @property (nonatomic, strong) FEMMapping *mapping;
15 | @property (nonatomic, getter=isToMany) BOOL toMany;
16 |
17 | @property (nonatomic) BOOL weak;
18 | @property (nonatomic, copy) FEMAssignmentPolicy assignmentPolicy;
19 |
20 | - (instancetype)init NS_UNAVAILABLE;
21 |
22 | - (instancetype)initWithProperty:(NSString *)property keyPath:(nullable NSString *)keyPath mapping:(FEMMapping *)mapping NS_DESIGNATED_INITIALIZER;
23 | - (instancetype)initWithProperty:(NSString *)property mapping:(FEMMapping *)mapping;
24 | - (instancetype)initWithProperty:(NSString *)property keyPath:(NSString *)keyPath mapping:(FEMMapping *)mapping assignmentPolicy:(FEMAssignmentPolicy)assignmentPolicy;
25 |
26 | - (void)setMapping:(FEMMapping *)mapping forKeyPath:(nullable NSString *)keyPath;
27 |
28 | @end
29 |
30 | @interface FEMRelationship (Deprecated)
31 |
32 | - (void)setObjectMapping:(FEMMapping *)objectMapping forKeyPath:(nullable NSString *)keyPath __attribute__((deprecated("Use -[FEMRelationship setMappaing:forKeyPath:] instead")));
33 |
34 | - (instancetype)initWithProperty:(NSString *)property
35 | keyPath:(nullable NSString *)keyPath
36 | assignmentPolicy:(nullable FEMAssignmentPolicy)policy
37 | objectMapping:(nullable FEMMapping *)objectMapping __attribute__((deprecated("Use -[FEMRelationship initWithProperty:keyPath:mapping:assignmentPolicy:] instead")));
38 |
39 | /**
40 | * same as + [FEMRelationship mappingOfProperty:property toKeyPath:nil mapping:mapping];
41 | */
42 | + (instancetype)mappingOfProperty:(NSString *)property objectMapping:(FEMMapping *)objectMapping __attribute__((deprecated("Use -[FEMRelationship initWithProperty:mapping:] instead")));
43 |
44 | + (instancetype)mappingOfProperty:(NSString *)property
45 | toKeyPath:(nullable NSString *)keyPath
46 | objectMapping:(FEMMapping *)objectMapping __attribute__((deprecated("Use -[FEMRelationship initWithProperty:keyPath:mapping:] instead")));
47 |
48 | @property (nonatomic, strong) FEMMapping *objectMapping __attribute__((deprecated("Use FEMRelationship.mapping instead")));
49 |
50 | @end
51 |
52 | @interface FEMRelationship (Unavailable)
53 |
54 | + (instancetype)mappingOfProperty:(NSString *)property
55 | configuration:(void (^)(FEMRelationship *__mapping))configuration __attribute__((unavailable("Use -[FEMRelationship initWithProperty:keyPath:mapping:] instead")));
56 |
57 | + (instancetype)mappingOfProperty:(NSString *)property
58 | toKeyPath:(nullable NSString *)keyPath
59 | configuration:(void (^)(FEMRelationship *__mapping))configuration __attribute__((unavailable("Use -[FEMRelationship initWithProperty:keyPath:mapping:] instead")));
60 |
61 | @end
62 |
63 | NS_ASSUME_NONNULL_END
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Core/Mapping/FEMRelationship.m:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import "FEMRelationship.h"
4 | #import "FEMMapping.h"
5 |
6 | @implementation FEMRelationship
7 |
8 | @synthesize property = _property;
9 | @synthesize keyPath = _keyPath;
10 |
11 | #pragma mark - Init
12 |
13 | - (instancetype)initWithProperty:(NSString *)property mapping:(FEMMapping *)mapping {
14 | return [self initWithProperty:property keyPath:nil mapping:mapping];
15 | }
16 |
17 | - (instancetype)initWithProperty:(NSString *)property keyPath:(NSString *)keyPath mapping:(FEMMapping *)mapping {
18 | self = [super init];
19 | if (self) {
20 | self.property = property;
21 | self.keyPath = keyPath;
22 | self.mapping = mapping;
23 | self.assignmentPolicy = FEMAssignmentPolicyAssign;
24 | }
25 |
26 | return self;
27 | }
28 |
29 | - (instancetype)initWithProperty:(NSString *)property keyPath:(NSString *)keyPath mapping:(FEMMapping *)mapping assignmentPolicy:(FEMAssignmentPolicy)assignmentPolicy {
30 | self = [self initWithProperty:property keyPath:keyPath mapping:mapping];
31 | if (self) {
32 | self.assignmentPolicy = assignmentPolicy;
33 | }
34 | return self;
35 | }
36 |
37 | #pragma mark - Shortcut
38 |
39 | - (void)setMapping:(nonnull FEMMapping *)mapping forKeyPath:(nullable NSString *)keyPath {
40 | self.mapping = mapping;
41 | self.keyPath = keyPath;
42 | }
43 |
44 | #pragma mark - Description
45 |
46 | - (NSString *)description {
47 | return [NSString stringWithFormat:
48 | @"<%@ %p>\n {\nproperty:%@ keyPath:%@ toMany:%@\nmapping:(%@)}\n",
49 | NSStringFromClass(self.class),
50 | (__bridge void *) self,
51 | self.property,
52 | self.keyPath,
53 | @(self.toMany),
54 | [self.mapping description]
55 | ];
56 | }
57 |
58 | @end
59 |
60 | @implementation FEMRelationship (Deprecated)
61 |
62 | @dynamic objectMapping;
63 |
64 | - (FEMMapping *)objectMapping {
65 | return self.mapping;
66 | }
67 |
68 | - (void)setObjectMapping:(FEMMapping *)objectMapping {
69 | self.mapping = objectMapping;
70 | }
71 |
72 | + (instancetype)mappingOfProperty:(NSString *)property keyPath:(NSString *)keyPath objectMapping:(FEMMapping *)objectMapping {
73 | return [[self alloc] initWithProperty:property keyPath:keyPath mapping:objectMapping];
74 | }
75 |
76 | #pragma mark - Init
77 |
78 | - (instancetype)initWithProperty:(NSString *)property
79 | keyPath:(NSString *)keyPath
80 | assignmentPolicy:(FEMAssignmentPolicy)policy
81 | objectMapping:(FEMMapping *)objectMapping {
82 | return [self initWithProperty:property keyPath:keyPath mapping:objectMapping assignmentPolicy:policy];
83 | }
84 |
85 | + (instancetype)mappingOfProperty:(NSString *)property toKeyPath:(NSString *)keyPath objectMapping:(FEMMapping *)objectMapping {
86 | return [[self alloc] initWithProperty:property keyPath:keyPath mapping:objectMapping];
87 | }
88 |
89 | + (instancetype)mappingOfProperty:(NSString *)property objectMapping:(FEMMapping *)objectMapping {
90 | return [[self alloc] initWithProperty:property mapping:objectMapping];
91 | }
92 |
93 | #pragma mark - Property objectMapping
94 |
95 | - (void)setObjectMapping:(FEMMapping *)objectMapping forKeyPath:(NSString *)keyPath {
96 | [self setMapping:objectMapping forKeyPath:keyPath];
97 | }
98 |
99 | @end
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Core/Serializer/FEMSerializer.h:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import
4 | #import "FEMMapping.h"
5 | #import "FEMSerializer.h"
6 |
7 | @interface FEMSerializer : NSObject
8 |
9 | + (nonnull NSDictionary *)serializeObject:(nonnull id)object usingMapping:(nonnull FEMMapping *)mapping;
10 | + (nonnull id)serializeCollection:(nonnull NSArray *)collection usingMapping:(nonnull FEMMapping *)mapping;
11 |
12 | @end
13 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Core/Serializer/FEMSerializer.m:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import "FEMSerializer.h"
4 | #import "FEMAttribute.h"
5 | #import "FEMTypeIntrospection.h"
6 | #import "FEMRelationship.h"
7 |
8 | @implementation FEMSerializer
9 |
10 | + (NSDictionary *)_serializeObject:(id)object usingMapping:(FEMMapping *)mapping {
11 | NSMutableDictionary *representation = [NSMutableDictionary dictionary];
12 |
13 | for (FEMAttribute *fieldMapping in mapping.attributes) {
14 | [self setValueOnRepresentation:representation fromObject:object withFieldMapping:fieldMapping];
15 | }
16 |
17 | for (FEMRelationship *relationshipMapping in mapping.relationships) {
18 | [self setRelationshipObjectOn:representation usingMapping:relationshipMapping fromObject:object];
19 | }
20 |
21 | return representation;
22 | }
23 |
24 | + (NSDictionary *)serializeObject:(id)object usingMapping:(FEMMapping *)mapping {
25 | NSDictionary *representation = [self _serializeObject:object usingMapping:mapping];
26 |
27 | return mapping.rootPath.length > 0 ? @{mapping.rootPath : representation} : representation;
28 | }
29 |
30 | + (id)_serializeCollection:(NSArray *)collection usingMapping:(FEMMapping *)mapping {
31 | NSMutableArray *representation = [NSMutableArray new];
32 |
33 | for (id object in collection) {
34 | NSDictionary *objectRepresentation = [self _serializeObject:object usingMapping:mapping];
35 | [representation addObject:objectRepresentation];
36 | }
37 |
38 | return representation;
39 | }
40 |
41 | + (id)serializeCollection:(NSArray *)collection usingMapping:(FEMMapping *)mapping {
42 | NSArray *representation = [self _serializeCollection:collection usingMapping:mapping];
43 |
44 | return mapping.rootPath.length > 0 ? @{mapping.rootPath: representation} : representation;
45 | }
46 |
47 | + (void)setValueOnRepresentation:(NSMutableDictionary *)representation fromObject:(id)object withFieldMapping:(FEMAttribute *)fieldMapping {
48 | id returnedValue = [object valueForKey:fieldMapping.property];
49 | if (returnedValue) {
50 | returnedValue = [fieldMapping reverseMapValue:returnedValue] ?: [NSNull null];
51 |
52 | [self setValue:returnedValue forKeyPath:fieldMapping.keyPath inRepresentation:representation];
53 | }
54 | }
55 |
56 | + (void)setValue:(id)value forKeyPath:(NSString *)keyPath inRepresentation:(NSMutableDictionary *)representation {
57 | NSArray *keyPathComponents = [keyPath componentsSeparatedByString:@"."];
58 | if ([keyPathComponents count] == 1) {
59 | [representation setObject:value forKey:keyPath];
60 | } else if ([keyPathComponents count] > 1) {
61 | NSString *attributeKey = [keyPathComponents lastObject];
62 | NSMutableArray *subPaths = [NSMutableArray arrayWithArray:keyPathComponents];
63 | [subPaths removeLastObject];
64 |
65 | id currentPath = representation;
66 | for (NSString *key in subPaths) {
67 | id subPath = [currentPath valueForKey:key];
68 | if (subPath == nil) {
69 | subPath = [NSMutableDictionary new];
70 | [currentPath setValue:subPath forKey:key];
71 | }
72 | currentPath = subPath;
73 | }
74 | [currentPath setValue:value forKey:attributeKey];
75 | }
76 | }
77 |
78 | + (void)setRelationshipObjectOn:(NSMutableDictionary *)representation
79 | usingMapping:(FEMRelationship *)relationshipMapping
80 | fromObject:(id)object {
81 | id value = [object valueForKey:relationshipMapping.property];
82 | if (value) {
83 | id relationshipRepresentation = nil;
84 | if (relationshipMapping.isToMany) {
85 | relationshipRepresentation = [self _serializeCollection:value usingMapping:relationshipMapping.mapping];
86 | } else {
87 | relationshipRepresentation = [self _serializeObject:value usingMapping:relationshipMapping.mapping];
88 | }
89 |
90 | if (relationshipMapping.keyPath.length > 0) {
91 | [representation setObject:relationshipRepresentation forKey:relationshipMapping.keyPath];
92 | } else {
93 | NSParameterAssert([relationshipRepresentation isKindOfClass:NSDictionary.class]);
94 | [representation addEntriesFromDictionary:relationshipRepresentation];
95 | }
96 | }
97 | }
98 |
99 | @end
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Core/Store/FEMManagedObjectStore.h:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import "FEMObjectStore.h"
4 |
5 | NS_ASSUME_NONNULL_BEGIN
6 |
7 | @class NSManagedObjectContext;
8 |
9 | @interface FEMManagedObjectStore : FEMObjectStore
10 |
11 | - (instancetype)init NS_UNAVAILABLE;
12 |
13 | - (instancetype)initWithContext:(NSManagedObjectContext *)context NS_DESIGNATED_INITIALIZER;
14 | @property (nonatomic, strong, readonly) NSManagedObjectContext *context;
15 |
16 | @property (nonatomic) BOOL saveContextOnCommit;
17 |
18 | @end
19 |
20 | NS_ASSUME_NONNULL_END
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Core/Store/FEMManagedObjectStore.m:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import "FEMManagedObjectStore.h"
4 |
5 | #import
6 |
7 | #import "FEMManagedObjectMapping.h"
8 | #import "FEMManagedObjectCache.h"
9 |
10 | __attribute__((always_inline)) void validateMapping(FEMMapping *mapping) {
11 | NSCAssert(mapping.entityName != nil, @"Entity name can't be nil. Please, use -[FEMMapping initWithEntityName:]");
12 | }
13 |
14 | @implementation FEMManagedObjectStore {
15 | FEMManagedObjectCache *_cache;
16 | }
17 |
18 | #pragma mark - Init
19 |
20 | - (instancetype)initWithContext:(NSManagedObjectContext *)context {
21 | NSParameterAssert(context != nil);
22 | self = [super init];
23 | if (self) {
24 | _context = context;
25 | }
26 |
27 | return self;
28 | }
29 |
30 | #pragma mark - Transaction
31 |
32 | - (void)prepareTransactionForMapping:(nonnull FEMMapping *)mapping ofRepresentation:(nonnull NSArray *)representation {
33 | _cache = [[FEMManagedObjectCache alloc] initWithMapping:mapping representation:representation context:self.context];
34 | }
35 |
36 | - (void)beginTransaction {}
37 |
38 | - (NSError *)commitTransaction {
39 | _cache = nil;
40 |
41 | NSError *error = nil;
42 | if (self.saveContextOnCommit && self.context.hasChanges && ![self.context save:&error]) {
43 | return error;
44 | }
45 |
46 | return nil;
47 | }
48 |
49 |
50 |
51 | - (id)newObjectForMapping:(FEMMapping *)mapping {
52 | validateMapping(mapping);
53 |
54 | NSString *entityName = [mapping entityName];
55 | return [NSEntityDescription insertNewObjectForEntityForName:entityName inManagedObjectContext:self.context];
56 | }
57 |
58 | - (id)registeredObjectForRepresentation:(id)representation mapping:(FEMMapping *)mapping {
59 | validateMapping(mapping);
60 |
61 | return [_cache existingObjectForRepresentation:representation mapping:mapping];
62 | }
63 |
64 | - (void)registerObject:(id)object forMapping:(FEMMapping *)mapping {
65 | validateMapping(mapping);
66 |
67 | [_cache addExistingObject:object mapping:mapping];
68 | }
69 |
70 | - (NSDictionary *)registeredObjectsForMapping:(FEMMapping *)mapping {
71 | validateMapping(mapping);
72 |
73 | return [_cache existingObjectsForMapping:mapping];
74 | }
75 |
76 | - (BOOL)canRegisterObject:(id)object forMapping:(FEMMapping *)mapping {
77 | validateMapping(mapping);
78 |
79 | return mapping.primaryKey != nil && [object isInserted];
80 | }
81 |
82 | #pragma mark - FEMRelationshipAssignmentContextDelegate
83 |
84 | - (void)assignmentContext:(FEMRelationshipAssignmentContext *)context deletedObject:(id)object {
85 | NSAssert([object isKindOfClass:NSManagedObject.class], @"Wrong class");
86 | [self.context deleteObject:object];
87 | }
88 |
89 | @end
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Core/Store/FEMObjectStore.h:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import
4 |
5 | #import "FEMRelationshipAssignmentContext.h"
6 |
7 | @class FEMMapping;
8 |
9 | @interface FEMObjectStore : NSObject
10 |
11 | - (void)prepareTransactionForMapping:(nonnull FEMMapping *)mapping ofRepresentation:(nonnull NSArray *)representation;
12 | - (void)beginTransaction;
13 | - (nullable NSError *)commitTransaction;
14 |
15 | - (nonnull id)newObjectForMapping:(nonnull FEMMapping *)mapping;
16 | - (nonnull FEMRelationshipAssignmentContext *)newAssignmentContext;
17 |
18 | - (void)registerObject:(nonnull id)object forMapping:(nonnull FEMMapping *)mapping;
19 | - (BOOL)canRegisterObject:(nonnull id)object forMapping:(nonnull FEMMapping *)mapping;
20 |
21 | - (nonnull NSDictionary *)registeredObjectsForMapping:(nonnull FEMMapping *)mapping;
22 | - (nullable id)registeredObjectForRepresentation:(nonnull id)representation mapping:(nonnull FEMMapping *)mapping;
23 |
24 | @end
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Core/Store/FEMObjectStore.m:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import "FEMObjectStore.h"
4 | #import "FEMMapping.h"
5 |
6 | @implementation FEMObjectStore
7 |
8 | - (void)prepareTransactionForMapping:(nonnull FEMMapping *)mapping ofRepresentation:(nonnull NSArray *)representation {}
9 |
10 | - (void)beginTransaction {}
11 |
12 | - (NSError *)commitTransaction {
13 | return nil;
14 | }
15 |
16 | - (id)newObjectForMapping:(FEMMapping *)mapping {
17 | id object = [[mapping.objectClass alloc] init];
18 | return object;
19 | }
20 |
21 | - (FEMRelationshipAssignmentContext *)newAssignmentContext {
22 | FEMRelationshipAssignmentContext *context = [[FEMRelationshipAssignmentContext alloc] initWithStore:self];
23 | return context;
24 | }
25 |
26 | - (void)registerObject:(id)object forMapping:(FEMMapping *)mapping {
27 | // no-op
28 | }
29 |
30 | - (BOOL)canRegisterObject:(id)object forMapping:(FEMMapping *)mapping {
31 | return mapping.primaryKeyAttribute != nil;
32 | }
33 |
34 | - (NSDictionary *)registeredObjectsForMapping:(FEMMapping *)mapping {
35 | return nil;
36 | }
37 |
38 | - (id)registeredObjectForRepresentation:(id)representation mapping:(FEMMapping *)mapping {
39 | return nil;
40 | }
41 |
42 | #pragma mark - FEMRelationshipAssignmentContextDelegate
43 |
44 | - (void)assignmentContext:(FEMRelationshipAssignmentContext *)context deletedObject:(id)object {
45 | // no-op
46 | }
47 |
48 | @end
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Extensions/Collection/FEMExcludableCollection.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by zen on 19/06/14.
3 | // Copyright (c) 2014 Yalantis. All rights reserved.
4 | //
5 |
6 | #import
7 |
8 | @protocol FEMExcludableCollection
9 | @required
10 | - (id)collectionByExcludingObjects:(id)objects;
11 |
12 | @end
13 |
14 | @interface NSArray (FEMExcludableCollection)
15 |
16 | - (NSArray *)collectionByExcludingObjects:(NSArray *)objects;
17 |
18 | @end
19 |
20 | @interface NSSet (FEMExcludableCollection)
21 |
22 | - (NSSet *)collectionByExcludingObjects:(NSSet *)objects;
23 |
24 | @end
25 |
26 | @interface NSOrderedSet (FEMExcludableCollection)
27 |
28 | - (NSOrderedSet *)collectionByExcludingObjects:(NSOrderedSet *)objects;
29 |
30 | @end
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Extensions/Collection/FEMExcludableCollection.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by zen on 19/06/14.
3 | // Copyright (c) 2014 Yalantis. All rights reserved.
4 | //
5 |
6 | #import "FEMExcludableCollection.h"
7 |
8 |
9 | @implementation NSArray (FEMExcludableCollection)
10 |
11 | - (NSArray *)collectionByExcludingObjects:(NSArray *)array {
12 | return [[self mutableCopy] collectionByExcludingObjects:array];
13 | }
14 |
15 | @end
16 |
17 | @implementation NSMutableArray (FEMExcludableCollection)
18 |
19 | - (NSArray *)collectionByExcludingObjects:(NSArray *)objects {
20 | [self removeObjectsInArray:objects];
21 |
22 | return self;
23 | }
24 |
25 | @end
26 |
27 | @implementation NSSet (FEMExcludableCollection)
28 |
29 | - (NSSet *)collectionByExcludingObjects:(id)set {
30 | return [[self mutableCopy] collectionByExcludingObjects:set];
31 | }
32 |
33 | @end
34 |
35 | @implementation NSMutableSet (FEMExcludableCollection)
36 |
37 | - (NSSet *)collectionByExcludingObjects:(NSSet *)set {
38 | [self minusSet:set];
39 |
40 | return self;
41 | }
42 |
43 | @end
44 |
45 | @implementation NSOrderedSet (FEMExcludableCollection)
46 |
47 | - (NSOrderedSet *)collectionByExcludingObjects:(NSOrderedSet *)objects {
48 | return [[self mutableCopy] collectionByExcludingObjects:objects];
49 | }
50 |
51 | @end
52 |
53 | @implementation NSMutableOrderedSet (FEMExcludableCollection)
54 |
55 | - (NSOrderedSet *)collectionByExcludingObjects:(NSOrderedSet *)objects {
56 | [self minusOrderedSet:objects];
57 |
58 | return self;
59 | }
60 |
61 | @end
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Extensions/Collection/FEMMergeableCollection.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by zen on 12/08/14.
3 | // Copyright (c) 2014 Yalantis. All rights reserved.
4 | //
5 |
6 | #import
7 |
8 | @protocol FEMMergeableCollection
9 | @required
10 | - (id)collectionByMergingObjects:(id)object;
11 |
12 | @end
13 |
14 | @interface NSArray (FEMMergeableCollection)
15 |
16 | - (NSArray *)collectionByMergingObjects:(NSArray *)object;
17 |
18 | @end
19 |
20 | @interface NSSet (FEMMergeableCollection)
21 |
22 | - (NSSet *)collectionByMergingObjects:(NSSet *)object;
23 |
24 | @end
25 |
26 | @interface NSOrderedSet (FEMMergeableCollection)
27 |
28 | - (NSOrderedSet *)collectionByMergingObjects:(NSOrderedSet *)object;
29 |
30 | @end
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Extensions/Collection/FEMMergeableCollection.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by zen on 12/08/14.
3 | // Copyright (c) 2014 Yalantis. All rights reserved.
4 | //
5 |
6 | #import "FEMMergeableCollection.h"
7 |
8 | @implementation NSArray (FEMMergeableCollection)
9 |
10 | - (NSArray *)collectionByMergingObjects:(NSArray *)array {
11 | return [[self mutableCopy] collectionByMergingObjects:array];
12 | }
13 |
14 | @end
15 |
16 | @implementation NSMutableArray (FEMMergeableCollection)
17 |
18 | - (NSArray *)collectionByMergingObjects:(NSArray *)array {
19 | if (array.count == 0) return self;
20 |
21 | NSMutableSet *appendingObjectsSet = [[NSMutableSet alloc] initWithArray:array];
22 | [appendingObjectsSet minusSet:[NSSet setWithArray:self]];
23 |
24 | [self addObjectsFromArray:[appendingObjectsSet allObjects]];
25 |
26 | return self;
27 | }
28 |
29 | @end
30 |
31 | @implementation NSSet (FEMMergeableCollection)
32 |
33 | - (NSSet *)collectionByMergingObjects:(NSSet *)set {
34 | return [[self mutableCopy] collectionByMergingObjects:set];
35 | }
36 |
37 | @end
38 |
39 | @implementation NSMutableSet (FEMMergeableCollection)
40 |
41 | - (NSSet *)collectionByMergingObjects:(NSSet *)set {
42 | [self unionSet:set];
43 |
44 | return self;
45 | }
46 |
47 | @end
48 |
49 | @implementation NSOrderedSet (FEMMergeableCollection)
50 |
51 | - (NSOrderedSet *)collectionByMergingObjects:(NSOrderedSet *)orderedSet {
52 | return [[self mutableCopy] collectionByMergingObjects:orderedSet];
53 | }
54 |
55 | @end
56 |
57 | @implementation NSMutableOrderedSet (FEMMergeableCollection)
58 |
59 | - (NSOrderedSet *)collectionByMergingObjects:(NSOrderedSet *)orderedSet {
60 | [self unionOrderedSet:orderedSet];
61 |
62 | return self;
63 | }
64 |
65 | @end
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Extensions/Foundation/NSArray+FEMPropertyRepresentation.h:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import
4 | #import
5 |
6 | @interface NSArray (FEMPropertyRepresentation)
7 |
8 | - (id)fem_propertyRepresentation:(objc_property_t)property;
9 |
10 | @end
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Extensions/Foundation/NSArray+FEMPropertyRepresentation.m:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import "NSArray+FEMPropertyRepresentation.h"
4 |
5 | #import "FEMTypeIntrospection.h"
6 |
7 | @implementation NSArray (FEMPropertyRepresentation)
8 |
9 | - (id)fem_propertyRepresentation:(objc_property_t)property {
10 | id convertedObject = self;
11 | if (property) {
12 | NSString *type = FEMPropertyTypeStringRepresentation(property);
13 | if ([type isEqualToString:@"NSSet"]) {
14 | convertedObject = [NSSet setWithArray:self];
15 | }
16 | else if ([type isEqualToString:@"NSMutableSet"]) {
17 | convertedObject = [NSMutableSet setWithArray:self];
18 | }
19 | else if ([type isEqualToString:@"NSOrderedSet"]) {
20 | convertedObject = [NSOrderedSet orderedSetWithArray:self];
21 | }
22 | else if ([type isEqualToString:@"NSMutableOrderedSet"]) {
23 | convertedObject = [NSMutableOrderedSet orderedSetWithArray:self];
24 | }
25 | else if ([type isEqualToString:@"NSMutableArray"]) {
26 | convertedObject = [NSMutableArray arrayWithArray:self];
27 | }
28 | }
29 | return convertedObject;
30 | }
31 |
32 | @end
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Extensions/Foundation/NSObject+FEMKVCExtension.h:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import
4 |
5 | @interface NSObject (FEMKVCExtension)
6 |
7 | - (void)fem_setValueIfDifferent:(id)value forKey:(NSString *)key;
8 |
9 | @end
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Extensions/Foundation/NSObject+FEMKVCExtension.m:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import "NSObject+FEMKVCExtension.h"
4 |
5 | @implementation NSObject (FEMKVCExtension)
6 |
7 | - (void)fem_setValueIfDifferent:(id)value forKey:(NSString *)key {
8 | id _value = [self valueForKey:key];
9 |
10 | if (_value != value && ![_value isEqual:value]) {
11 | [self setValue:value forKey:key];
12 | }
13 | }
14 |
15 | @end
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/FastEasyMapping.h:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #ifndef _FASTEASYMAPPING_
4 | #define _FASTEASYMAPPING_
5 |
6 | #import "FEMProperty.h"
7 | #import "FEMAttribute.h"
8 | #import "FEMRelationship.h"
9 |
10 | #import "FEMObjectStore.h"
11 | #import "FEMManagedObjectStore.h"
12 |
13 | #import "FEMMapping.h"
14 | #import "FEMObjectMapping.h"
15 | #import "FEMManagedObjectMapping.h"
16 |
17 | #import "FEMDeserializer.h"
18 | #import "FEMObjectDeserializer.h"
19 | #import "FEMManagedObjectDeserializer.h"
20 | #import "FEMSerializer.h"
21 |
22 | #import "FEMRelationshipAssignmentContext.h"
23 | #import "FEMAssignmentPolicy.h"
24 |
25 | #import "FEMTypes.h"
26 | #import "FEMRepresentationUtility.h"
27 | #import "FEMMappingUtility.h"
28 |
29 | #endif /* _FASTEASYMAPPING_ */
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Utility/FEMMappingUtility.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by zen on 14/05/15.
3 | // Copyright (c) 2015 Yalantis. All rights reserved.
4 | //
5 |
6 | @import Foundation;
7 |
8 | @class FEMMapping;
9 |
10 | FOUNDATION_EXTERN void FEMMappingApply(FEMMapping *mapping, void (^apply)(FEMMapping *object));
11 | FOUNDATION_EXTERN NSSet * FEMMappingCollectUsedEntityNames(FEMMapping *mapping);
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Utility/FEMMappingUtility.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by zen on 14/05/15.
3 | // Copyright (c) 2015 Yalantis. All rights reserved.
4 | //
5 |
6 | #import "FEMMappingUtility.h"
7 | #import "FEMMapping.h"
8 |
9 | void FEMMappingApply(FEMMapping *mapping, void (^apply)(FEMMapping *object)) {
10 | apply(mapping);
11 |
12 | for (FEMRelationship *relationship in mapping.relationships) {
13 | FEMMappingApply(relationship.mapping, apply);
14 | }
15 | }
16 |
17 | NSSet * FEMMappingCollectUsedEntityNames(FEMMapping *mapping) {
18 | NSMutableSet *output = [[NSMutableSet alloc] init];
19 | FEMMappingApply(mapping, ^(FEMMapping *object) {
20 | NSCParameterAssert(object.entityName != nil);
21 |
22 | [output addObject:object.entityName];
23 | });
24 |
25 | return output;
26 | }
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Utility/FEMRepresentationUtility.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by zen on 12/05/15.
3 | // Copyright (c) 2015 Yalantis. All rights reserved.
4 | //
5 |
6 | #import
7 |
8 | @class FEMMapping, FEMAttribute;
9 |
10 | FOUNDATION_EXTERN id FEMRepresentationRootForKeyPath(id representation, NSString *keyPath);
11 |
12 | FOUNDATION_EXTERN NSDictionary *FEMRepresentationCollectPresentedPrimaryKeys(id representation, FEMMapping *mapping);
13 |
14 | FOUNDATION_EXTERN id FEMRepresentationValueForAttribute(id representation, FEMAttribute *attribute);
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Utility/FEMRepresentationUtility.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by zen on 12/05/15.
3 | // Copyright (c) 2015 Yalantis. All rights reserved.
4 | //
5 |
6 | #import "FEMRepresentationUtility.h"
7 | #import "FEMMapping.h"
8 | #import "FEMMappingUtility.h"
9 | #import "FEMAttribute.h"
10 |
11 | id FEMRepresentationRootForKeyPath(id representation, NSString *keyPath) {
12 | if (keyPath.length > 0) {
13 | return [representation valueForKeyPath:keyPath];
14 | }
15 |
16 | return representation;
17 | }
18 |
19 | void _FEMRepresentationCollectPresentedPrimaryKeys(id, FEMMapping *, NSDictionary *);
20 |
21 | void _FEMRepresentationCollectObjectPrimaryKeys(NSDictionary *object, FEMMapping *mapping, NSDictionary *container) {
22 | if (mapping.primaryKey) {
23 | FEMAttribute *primaryKeyMapping = mapping.primaryKeyAttribute;
24 | id primaryKeyValue = FEMRepresentationValueForAttribute(object, primaryKeyMapping);
25 | if (primaryKeyValue && primaryKeyValue != NSNull.null) {
26 | NSMutableSet *set = container[mapping.entityName];
27 | [set addObject:primaryKeyValue];
28 | }
29 | }
30 |
31 | for (FEMRelationship *relationship in mapping.relationships) {
32 | id relationshipRepresentation = FEMRepresentationRootForKeyPath(object, relationship.keyPath);
33 | if (relationshipRepresentation && relationshipRepresentation != NSNull.null) {
34 | _FEMRepresentationCollectPresentedPrimaryKeys(relationshipRepresentation, relationship.mapping, container);
35 | }
36 | }
37 | }
38 |
39 | void _FEMRepresentationCollectPresentedPrimaryKeys(id representation, FEMMapping *mapping, NSDictionary *container) {
40 | if ([representation isKindOfClass:NSArray.class]) {
41 | for (id object in (id)representation) {
42 | _FEMRepresentationCollectObjectPrimaryKeys(object, mapping, container);
43 | }
44 | } else if ([representation isKindOfClass:NSDictionary.class] || [representation isKindOfClass:[NSNumber class]] || [representation isKindOfClass:[NSString class]]) {
45 | _FEMRepresentationCollectObjectPrimaryKeys(representation, mapping, container);
46 | } else {
47 | NSCAssert(
48 | NO,
49 | @"Expected container classes: NSArray, NSDictionary, NSNumber or NSString. Got:%@",
50 | NSStringFromClass([representation class])
51 | );
52 | }
53 | };
54 | NSDictionary *FEMRepresentationCollectPresentedPrimaryKeys(id representation, FEMMapping *mapping) {
55 | FEMMappingApply(mapping, ^(FEMMapping *object) {
56 | NSCParameterAssert(object.entityName != nil);
57 | });
58 |
59 | NSMutableDictionary *output = [[NSMutableDictionary alloc] init];
60 | for (NSString *name in FEMMappingCollectUsedEntityNames(mapping)) {
61 | output[name] = [[NSMutableSet alloc] init];
62 | }
63 |
64 | id root = FEMRepresentationRootForKeyPath(representation, mapping.rootPath);
65 | _FEMRepresentationCollectPresentedPrimaryKeys(root, mapping, output);
66 |
67 | return output;
68 | }
69 |
70 | id FEMRepresentationValueForAttribute(id representation, FEMAttribute *attribute) {
71 | id value = attribute.keyPath ? [representation valueForKeyPath:attribute.keyPath] : representation;
72 | // nil is a valid value for missing keys. therefore attribute is discarded
73 | if (value != nil) {
74 | // if by mistake nil returned we still have to map it to the NSNull to indicate missing value
75 | return [attribute mapValue:value] ?: [NSNull null];
76 | }
77 |
78 | return value;
79 | }
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Utility/FEMTypeIntrospection.h:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import
4 | #import
5 |
6 | extern BOOL FEMObjectPropertyTypeIsScalar(id object, NSString *propertyName);
7 |
8 | extern NSString * FEMPropertyTypeStringRepresentation(objc_property_t property);
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Utility/FEMTypeIntrospection.m:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 |
3 | #import "FEMTypeIntrospection.h"
4 | #import
5 |
6 | static const char ScalarTypeEncodings[] = {
7 | _C_BOOL, _C_BFLD, // BOOL
8 | _C_CHR, _C_UCHR, // char, unsigned char
9 | _C_SHT, _C_USHT, // short, unsigned short
10 | _C_INT, _C_UINT, // int, unsigned int, NSInteger, NSUInteger
11 | _C_LNG, _C_ULNG, // long, unsigned long
12 | _C_LNG_LNG, _C_ULNG_LNG, // long long, unsigned long long
13 | _C_FLT, _C_DBL, // float, CGFloat, double
14 | 0
15 | };
16 |
17 | BOOL FEMObjectPropertyTypeIsScalar(id object, NSString *propertyName) {
18 | objc_property_t property = class_getProperty(object_getClass(object), [propertyName UTF8String]);
19 | NSString *type = property ? FEMPropertyTypeStringRepresentation(property) : nil;
20 |
21 | return (type.length == 1) && (NSNotFound != [@(ScalarTypeEncodings) rangeOfString:type].location);
22 | }
23 |
24 | NSString * FEMPropertyTypeStringRepresentation(objc_property_t property) {
25 | const char *TypeAttribute = "T";
26 | char *type = property_copyAttributeValue(property, TypeAttribute);
27 | NSString *propertyType = (type[0] != _C_ID) ? @(type) : ({
28 | (type[1] == 0) ? @"id" : ({
29 | // Modern format of a type attribute (e.g. @"NSSet")
30 | type[strlen(type) - 1] = 0;
31 | @(type + 2);
32 | });
33 | });
34 | free(type);
35 | return propertyType;
36 | }
--------------------------------------------------------------------------------
/Benchmark/Vendor/FastEasyMapping/Utility/FEMTypes.h:
--------------------------------------------------------------------------------
1 | // For License please refer to LICENSE file in the root of FastEasyMapping project
2 | #import
3 |
4 | typedef __nullable id (^FEMMapBlock)(__nonnull id value);
--------------------------------------------------------------------------------
/Benchmark/Vendor/JSONModel/JSONModel/JSONModelArray.h:
--------------------------------------------------------------------------------
1 | //
2 | // JSONModelArray.h
3 | //
4 | // @version 0.8.0
5 | // @author Marin Todorov (http://www.underplot.com) and contributors
6 | //
7 |
8 | // Copyright (c) 2012-2015 Marin Todorov, Underplot ltd.
9 | // This code is distributed under the terms and conditions of the MIT license.
10 | //
11 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14 | //
15 |
16 |
17 | #import
18 |
19 | /**
20 | * **Don't make instances of JSONModelArray yourself, except you know what you are doing.**
21 | *
22 | * You get automatically JSONModelArray instances, when you declare a convert on demand property, like so:
23 | *
24 | * @property (strong, nonatomic) NSArray<JSONModel, ConvertOnDemand>* list;
25 | *
26 | * The class stores its contents as they come from JSON, and upon the first request
27 | * of each of the objects stored in the array, it'll be converted to the target model class.
28 | * Thus saving time upon the very first model creation.
29 | */
30 | @interface JSONModelArray : NSObject
31 |
32 | /**
33 | * Don't make instances of JSONModelArray yourself, except you know what you are doing.
34 | *
35 | * @param array an array of NSDictionary objects
36 | * @param cls the JSONModel sub-class you'd like the NSDictionaries to be converted to on demand
37 | */
38 | - (id)initWithArray:(NSArray *)array modelClass:(Class)cls;
39 |
40 | - (id)objectAtIndex:(NSUInteger)index;
41 | - (id)objectAtIndexedSubscript:(NSUInteger)index;
42 | - (void)forwardInvocation:(NSInvocation *)anInvocation;
43 | - (NSUInteger)count;
44 | - (id)firstObject;
45 | - (id)lastObject;
46 |
47 | /**
48 | * Looks up the array's contents and tries to find a JSONModel object
49 | * with matching index property value to the indexValue param.
50 | *
51 | * Will return nil if no matching model is found. Will return nil if there's no index property
52 | * defined on the models found in the array (will sample the first object, assuming the array
53 | * contains homogeneous collection of objects)
54 | *
55 | * @param indexValue the id value to search for
56 | * @return the found model or nil
57 | */
58 | - (id)modelWithIndexValue:(id)indexValue;
59 |
60 | @end
61 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/JSONModel/JSONModel/JSONModelClassProperty.h:
--------------------------------------------------------------------------------
1 | //
2 | // JSONModelClassProperty.h
3 | //
4 | // @version 1.2
5 | // @author Marin Todorov (http://www.underplot.com) and contributors
6 | //
7 |
8 | // Copyright (c) 2012-2015 Marin Todorov, Underplot ltd.
9 | // This code is distributed under the terms and conditions of the MIT license.
10 | //
11 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14 | //
15 |
16 |
17 | #import
18 |
19 | enum kCustomizationTypes {
20 | kNotInspected = 0,
21 | kCustom,
22 | kNo
23 | };
24 |
25 | typedef enum kCustomizationTypes PropertyGetterType;
26 |
27 | /**
28 | * **You do not need to instantiate this class yourself.** This class is used internally by JSONModel
29 | * to inspect the declared properties of your model class.
30 | *
31 | * Class to contain the information, representing a class property
32 | * It features the property's name, type, whether it's a required property,
33 | * and (optionally) the class protocol
34 | */
35 | @interface JSONModelClassProperty : NSObject
36 |
37 | /** The name of the declared property (not the ivar name) */
38 | @property (copy, nonatomic) NSString* name;
39 |
40 | /** A property class type */
41 | @property (assign, nonatomic) Class type;
42 |
43 | /** Struct name if a struct */
44 | @property (strong, nonatomic) NSString* structName;
45 |
46 | /** The name of the protocol the property conforms to (or nil) */
47 | @property (copy, nonatomic) NSString* protocol;
48 |
49 | /** If YES, it can be missing in the input data, and the input would be still valid */
50 | @property (assign, nonatomic) BOOL isOptional;
51 |
52 | /** If YES - don't call any transformers on this property's value */
53 | @property (assign, nonatomic) BOOL isStandardJSONType;
54 |
55 | /** If YES - create a mutable object for the value of the property */
56 | @property (assign, nonatomic) BOOL isMutable;
57 |
58 | /** If YES - create models on demand for the array members */
59 | @property (assign, nonatomic) BOOL convertsOnDemand;
60 |
61 | /** If YES - the value of this property determines equality to other models */
62 | @property (assign, nonatomic) BOOL isIndex;
63 |
64 | /** The status of property getter introspection in a model */
65 | @property (assign, nonatomic) PropertyGetterType getterType;
66 |
67 | /** a custom getter for this property, found in the owning model */
68 | @property (assign, nonatomic) SEL customGetter;
69 |
70 | /** custom setters for this property, found in the owning model */
71 | @property (strong, nonatomic) NSMutableDictionary *customSetters;
72 |
73 | @end
74 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/JSONModel/JSONModel/JSONModelClassProperty.m:
--------------------------------------------------------------------------------
1 | //
2 | // JSONModelClassProperty.m
3 | //
4 | // @version 1.2
5 | // @author Marin Todorov (http://www.underplot.com) and contributors
6 | //
7 |
8 | // Copyright (c) 2012-2015 Marin Todorov, Underplot ltd.
9 | // This code is distributed under the terms and conditions of the MIT license.
10 | //
11 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14 | //
15 |
16 |
17 | #import "JSONModelClassProperty.h"
18 |
19 | @implementation JSONModelClassProperty
20 |
21 | -(NSString*)description
22 | {
23 | //build the properties string for the current class property
24 | NSMutableArray* properties = [NSMutableArray arrayWithCapacity:8];
25 |
26 | if (self.isIndex) [properties addObject:@"Index"];
27 | if (self.isOptional) [properties addObject:@"Optional"];
28 | if (self.isMutable) [properties addObject:@"Mutable"];
29 | if (self.convertsOnDemand) [properties addObject:@"ConvertOnDemand"];
30 | if (self.isStandardJSONType) [properties addObject:@"Standard JSON type"];
31 | if (self.customGetter) [properties addObject:[NSString stringWithFormat: @"Getter = %@", NSStringFromSelector(self.customGetter)]];
32 |
33 | if (self.customSetters)
34 | {
35 | NSMutableArray *setters = [NSMutableArray array];
36 |
37 | for (id obj in self.customSetters.allValues)
38 | {
39 | if (obj != [NSNull null])
40 | [setters addObject:obj];
41 | }
42 |
43 | [properties addObject:[NSString stringWithFormat: @"Setters = [%@]", [setters componentsJoinedByString:@", "]]];
44 | }
45 |
46 | NSString* propertiesString = @"";
47 | if (properties.count>0) {
48 | propertiesString = [NSString stringWithFormat:@"(%@)", [properties componentsJoinedByString:@", "]];
49 | }
50 |
51 | //return the name, type and additional properties
52 | return [NSString stringWithFormat:@"@property %@%@ %@ %@",
53 | self.type?[NSString stringWithFormat:@"%@*",self.type]:(self.structName?self.structName:@"primitive"),
54 | self.protocol?[NSString stringWithFormat:@"<%@>", self.protocol]:@"",
55 | self.name,
56 | propertiesString
57 | ];
58 | }
59 |
60 | @end
61 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/JSONModel/JSONModelCategories/NSArray+JSONModel.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSArray+JSONModel.h
3 | //
4 | // @version 1.2
5 | // @author Marin Todorov (http://www.underplot.com) and contributors
6 | //
7 |
8 | // Copyright (c) 2012-2015 Marin Todorov, Underplot ltd.
9 | // This code is distributed under the terms and conditions of the MIT license.
10 | //
11 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14 | //
15 |
16 |
17 |
18 | #import
19 | #import "JSONModel.h"
20 |
21 | /**
22 | * Exposes invisible JSONModelArray methods
23 | */
24 | @interface NSArray(JSONModel)
25 |
26 | /**
27 | * Looks up the array's contents and tries to find a JSONModel object
28 | * with matching index property value to the indexValue param.
29 | *
30 | * Will return nil if no matching model is found. Will return nil if there's no index property
31 | * defined on the models found in the array (will sample the first object, assuming the array
32 | * contains homogeneous collection of objects)
33 | *
34 | * @param indexValue the id value to search for
35 | * @return the found model or nil
36 | * @exception NSException throws exception if you call this method on an instance, which is not actually a JSONModelArray
37 | */
38 | - (id)modelWithIndexValue:(id)indexValue;
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/JSONModel/JSONModelCategories/NSArray+JSONModel.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSArray+JSONModel.m
3 | //
4 | // @version 1.2
5 | // @author Marin Todorov (http://www.underplot.com) and contributors
6 | //
7 |
8 | // Copyright (c) 2012-2015 Marin Todorov, Underplot ltd.
9 | // This code is distributed under the terms and conditions of the MIT license.
10 | //
11 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14 | //
15 |
16 |
17 |
18 | #import "NSArray+JSONModel.h"
19 |
20 | @implementation NSArray(JSONModel)
21 |
22 | - (id)modelWithIndexValue:(id)indexValue
23 | {
24 | NSAssert(NO, @"call modelWithIndexValue: on a ConvertOnDemand property, which is defined like that: @property (strong, nonatomic) NSArray* list;");
25 | return nil;
26 | }
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/JSONModel/JSONModelLib.h:
--------------------------------------------------------------------------------
1 | //
2 | // JSONModelLib.h
3 | //
4 | // @version 1.2
5 | // @author Marin Todorov (http://www.underplot.com) and contributors
6 | //
7 |
8 | // Copyright (c) 2012-2015 Marin Todorov, Underplot ltd.
9 | // This code is distributed under the terms and conditions of the MIT license.
10 | //
11 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14 | //
15 |
16 |
17 | #import
18 |
19 | //JSONModel transformations
20 | #import "JSONValueTransformer.h"
21 | #import "JSONKeyMapper.h"
22 |
23 | //basic JSONModel classes
24 | #import "JSONModelError.h"
25 | #import "JSONModelClassProperty.h"
26 | #import "JSONModel.h"
27 |
28 | //network classes
29 | #import "JSONHTTPClient.h"
30 | #import "JSONModel+networking.h"
31 | #import "JSONAPI.h"
32 |
33 | //models array
34 | #import "NSArray+JSONModel.h"
35 | #import "JSONModelArray.h"
36 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/JSONModel/JSONModelNetworking/JSONModel+networking.h:
--------------------------------------------------------------------------------
1 | //
2 | // JSONModel+networking.h
3 | //
4 | // @version 1.2
5 | // @author Marin Todorov (http://www.underplot.com) and contributors
6 | //
7 |
8 | // Copyright (c) 2012-2015 Marin Todorov, Underplot ltd.
9 | // This code is distributed under the terms and conditions of the MIT license.
10 | //
11 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14 | //
15 |
16 |
17 | #import "JSONModel.h"
18 | #import "JSONHTTPClient.h"
19 |
20 | typedef void (^JSONModelBlock)(id model, JSONModelError* err);
21 |
22 | /**
23 | * The JSONModel(networking) class category adds networking to JSONModel.
24 | * It adds initFromURLWithString: initializer, which makes a GET http request
25 | * to the URL given and initializes the model with the returned JSON.
26 | * Use #import "JSONModel+networking.h" to import networking capabilities.
27 | */
28 | @interface JSONModel(Networking)
29 |
30 | @property (assign, nonatomic) BOOL isLoading;
31 | /** @name Asynchronously create a model over the network */
32 | /**
33 | * Asynchronously create a model over the network. Create a new model instance and initialize it with the JSON fetched from the given URL
34 | * @param urlString the absolute URL address of the JSON feed as a string
35 | * @param completeBlock JSONModelBlock executed upon completion. The JSONModelBlock type is defined as: void (^JSONModelBlock)(JSONModel* model, JSONModelError* e); the first parameter is the initialized model or nil,
36 | * and second parameter holds the model initialization error, if any
37 | */
38 | -(instancetype)initFromURLWithString:(NSString *)urlString completion:(JSONModelBlock)completeBlock;
39 |
40 | /**
41 | * Asynchronously gets the contents of a URL and constructs a JSONModel object from the response.
42 | * The constructed JSONModel object passed as the first parameter to the completion block will be of the same
43 | * class as the receiver. So call this method on yourJSONModel sub-class rather than directly on JSONModel.
44 | * @param urlString The absolute URL of the JSON resource, as a string
45 | * @param completeBlock The block to be called upon completion.
46 | * JSONModelBlock type is defined as: void (^JSONModelBlock)(JSONModel* model, JSONModelError* err);
47 | * The first parameter is the initialized model (of the same JSONModel sub-class as the receiver) or nil if there was an error;
48 | * The second parameter is the initialization error, if any.
49 | */
50 | + (void)getModelFromURLWithString:(NSString*)urlString completion:(JSONModelBlock)completeBlock;
51 |
52 | /**
53 | * Asynchronously posts a JSONModel object (as JSON) to a URL and constructs a JSONModel object from the response.
54 | * The constructed JSONModel object passed as the first parameter to the completion block will be of the same
55 | * class as the receiver. So call this method on yourJSONModel sub-class rather than directly on JSONModel.
56 | * @param post A JSONModel object that will be converted to JSON and sent as the POST data to the HTTP request.
57 | * @param urlString The absolute URL of the JSON resource, as a string
58 | * @param completeBlock The block to be called upon completion.
59 | * JSONModelBlock type is defined as: void (^JSONModelBlock)(JSONModel* model, JSONModelError* err);
60 | * The first parameter is the initialized model (of the same JSONModel sub-class as the receiver) or nil if there was an error;
61 | * The second parameter is the initialization error, if any.
62 | */
63 | + (void)postModel:(JSONModel*)post toURLWithString:(NSString*)urlString completion:(JSONModelBlock)completeBlock;
64 |
65 |
66 | @end
67 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/JSONModel/JSONModelNetworking/JSONModel+networking.m:
--------------------------------------------------------------------------------
1 | //
2 | // JSONModel+networking.m
3 | //
4 | // @version 1.2
5 | // @author Marin Todorov (http://www.underplot.com) and contributors
6 | //
7 |
8 | // Copyright (c) 2012-2015 Marin Todorov, Underplot ltd.
9 | // This code is distributed under the terms and conditions of the MIT license.
10 | //
11 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14 | //
15 |
16 |
17 | #import "JSONModel+networking.h"
18 | #import "JSONHTTPClient.h"
19 |
20 | BOOL _isLoading;
21 |
22 | @implementation JSONModel(Networking)
23 |
24 | @dynamic isLoading;
25 |
26 | -(BOOL)isLoading
27 | {
28 | return _isLoading;
29 | }
30 |
31 | -(void)setIsLoading:(BOOL)isLoading
32 | {
33 | _isLoading = isLoading;
34 | }
35 |
36 | -(instancetype)initFromURLWithString:(NSString *)urlString completion:(JSONModelBlock)completeBlock
37 | {
38 | id placeholder = [super init];
39 | __block id blockSelf = self;
40 |
41 | if (placeholder) {
42 | //initialization
43 | self.isLoading = YES;
44 |
45 | [JSONHTTPClient getJSONFromURLWithString:urlString
46 | completion:^(NSDictionary *json, JSONModelError* e) {
47 |
48 | JSONModelError* initError = nil;
49 | blockSelf = [self initWithDictionary:json error:&initError];
50 |
51 | if (completeBlock) {
52 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_MSEC), dispatch_get_main_queue(), ^{
53 | completeBlock(blockSelf, e?e:initError );
54 | });
55 | }
56 |
57 | self.isLoading = NO;
58 |
59 | }];
60 | }
61 | return placeholder;
62 | }
63 |
64 | + (void)getModelFromURLWithString:(NSString*)urlString completion:(JSONModelBlock)completeBlock
65 | {
66 | [JSONHTTPClient getJSONFromURLWithString:urlString
67 | completion:^(NSDictionary* jsonDict, JSONModelError* err)
68 | {
69 | JSONModel* model = nil;
70 |
71 | if(err == nil)
72 | {
73 | model = [[self alloc] initWithDictionary:jsonDict error:&err];
74 | }
75 |
76 | if(completeBlock != nil)
77 | {
78 | dispatch_async(dispatch_get_main_queue(), ^
79 | {
80 | completeBlock(model, err);
81 | });
82 | }
83 | }];
84 | }
85 |
86 | + (void)postModel:(JSONModel*)post toURLWithString:(NSString*)urlString completion:(JSONModelBlock)completeBlock
87 | {
88 | [JSONHTTPClient postJSONFromURLWithString:urlString
89 | bodyString:[post toJSONString]
90 | completion:^(NSDictionary* jsonDict, JSONModelError* err)
91 | {
92 | JSONModel* model = nil;
93 |
94 | if(err == nil)
95 | {
96 | model = [[self alloc] initWithDictionary:jsonDict error:&err];
97 | }
98 |
99 | if(completeBlock != nil)
100 | {
101 | dispatch_async(dispatch_get_main_queue(), ^
102 | {
103 | completeBlock(model, err);
104 | });
105 | }
106 | }];
107 | }
108 |
109 | @end
110 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/MJExtension/MJDictionaryCache.h:
--------------------------------------------------------------------------------
1 | //
2 | // MJDictionaryCache.h
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 15/8/22.
6 | // Copyright (c) 2015年 小码哥. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MJDictionaryCache : NSObject
12 | /**
13 | * 缓存数据
14 | *
15 | * @param dictId 字典标识
16 | *
17 | * @return 缓存的字典
18 | */
19 | + (id)setObject:(id)object forKey:(id)key forDictId:(const void *)dictId;
20 |
21 | /**
22 | * 获得缓存的数据
23 | *
24 | * @param dictId 字典标识
25 | */
26 | + (id)objectForKey:(id)key forDictId:(const void *)dictId;
27 |
28 | /**
29 | * 获得缓存的字典
30 | *
31 | * @param dictId 字典标识
32 | */
33 | + (id)dictWithDictId:(const void *)dictId;
34 | @end
35 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/MJExtension/MJDictionaryCache.m:
--------------------------------------------------------------------------------
1 | //
2 | // MJDictionaryCache.m
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 15/8/22.
6 | // Copyright (c) 2015年 小码哥. All rights reserved.
7 | //
8 |
9 | #import "MJDictionaryCache.h"
10 | #import
11 |
12 | @implementation MJDictionaryCache
13 | + (id)setObject:(id)object forKey:(id)key forDictId:(const void *)dictId
14 | {
15 | // 获得字典
16 | NSMutableDictionary *dict = [self dictWithDictId:dictId];
17 | if (dict == nil) {
18 | dict = [NSMutableDictionary dictionary];
19 | objc_setAssociatedObject(self, dictId, dict, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
20 | }
21 |
22 | // 存储数据
23 | dict[key] = object;
24 |
25 | return dict;
26 | }
27 |
28 | + (id)objectForKey:(id)key forDictId:(const void *)dictId
29 | {
30 | return [self dictWithDictId:dictId][key];
31 | }
32 |
33 | + (id)dictWithDictId:(const void *)dictId
34 | {
35 | return objc_getAssociatedObject(self, dictId);
36 | }
37 | @end
--------------------------------------------------------------------------------
/Benchmark/Vendor/MJExtension/MJExtension.h:
--------------------------------------------------------------------------------
1 | //
2 | // MJExtension.h
3 | // MJExtension
4 | //
5 | // Created by mj on 14-1-15.
6 | // Copyright (c) 2014年 小码哥. All rights reserved.
7 | // 代码地址:https://github.com/CoderMJLee/MJExtension
8 | // 代码地址:http://code4app.com/ios/%E5%AD%97%E5%85%B8-JSON-%E4%B8%8E%E6%A8%A1%E5%9E%8B%E7%9A%84%E8%BD%AC%E6%8D%A2/5339992a933bf062608b4c57
9 |
10 | #import "NSObject+MJCoding.h"
11 | #import "NSObject+MJProperty.h"
12 | #import "NSObject+MJClass.h"
13 | #import "NSObject+MJKeyValue.h"
14 | #import "NSString+MJExtension.h"
15 | #import "MJExtensionConst.h"
--------------------------------------------------------------------------------
/Benchmark/Vendor/MJExtension/MJExtensionConst.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef __MJExtensionConst__H__
3 | #define __MJExtensionConst__H__
4 |
5 | #import
6 |
7 | // 过期
8 | #define MJExtensionDeprecated(instead) NS_DEPRECATED(2_0, 2_0, 2_0, 2_0, instead)
9 |
10 | // 构建错误
11 | #define MJExtensionBuildError(clazz, msg) \
12 | NSError *error = [NSError errorWithDomain:msg code:250 userInfo:nil]; \
13 | [clazz setMj_error:error];
14 |
15 | // 日志输出
16 | #ifdef DEBUG
17 | #define MJExtensionLog(...) NSLog(__VA_ARGS__)
18 | #else
19 | #define MJExtensionLog(...)
20 | #endif
21 |
22 | /**
23 | * 断言
24 | * @param condition 条件
25 | * @param returnValue 返回值
26 | */
27 | #define MJExtensionAssertError(condition, returnValue, clazz, msg) \
28 | [clazz setMj_error:nil]; \
29 | if ((condition) == NO) { \
30 | MJExtensionBuildError(clazz, msg); \
31 | return returnValue;\
32 | }
33 |
34 | #define MJExtensionAssert2(condition, returnValue) \
35 | if ((condition) == NO) return returnValue;
36 |
37 | /**
38 | * 断言
39 | * @param condition 条件
40 | */
41 | #define MJExtensionAssert(condition) MJExtensionAssert2(condition, )
42 |
43 | /**
44 | * 断言
45 | * @param param 参数
46 | * @param returnValue 返回值
47 | */
48 | #define MJExtensionAssertParamNotNil2(param, returnValue) \
49 | MJExtensionAssert2((param) != nil, returnValue)
50 |
51 | /**
52 | * 断言
53 | * @param param 参数
54 | */
55 | #define MJExtensionAssertParamNotNil(param) MJExtensionAssertParamNotNil2(param, )
56 |
57 | /**
58 | * 打印所有的属性
59 | */
60 | #define MJLogAllIvars \
61 | -(NSString *)description \
62 | { \
63 | return [self mj_keyValues].description; \
64 | }
65 | #define MJExtensionLogAllProperties MJLogAllIvars
66 |
67 | /**
68 | * 类型(属性类型)
69 | */
70 | extern NSString *const MJPropertyTypeInt;
71 | extern NSString *const MJPropertyTypeShort;
72 | extern NSString *const MJPropertyTypeFloat;
73 | extern NSString *const MJPropertyTypeDouble;
74 | extern NSString *const MJPropertyTypeLong;
75 | extern NSString *const MJPropertyTypeLongLong;
76 | extern NSString *const MJPropertyTypeChar;
77 | extern NSString *const MJPropertyTypeBOOL1;
78 | extern NSString *const MJPropertyTypeBOOL2;
79 | extern NSString *const MJPropertyTypePointer;
80 |
81 | extern NSString *const MJPropertyTypeIvar;
82 | extern NSString *const MJPropertyTypeMethod;
83 | extern NSString *const MJPropertyTypeBlock;
84 | extern NSString *const MJPropertyTypeClass;
85 | extern NSString *const MJPropertyTypeSEL;
86 | extern NSString *const MJPropertyTypeId;
87 |
88 | #endif
--------------------------------------------------------------------------------
/Benchmark/Vendor/MJExtension/MJExtensionConst.m:
--------------------------------------------------------------------------------
1 | #ifndef __MJExtensionConst__M__
2 | #define __MJExtensionConst__M__
3 |
4 | #import
5 |
6 | /**
7 | * 成员变量类型(属性类型)
8 | */
9 | NSString *const MJPropertyTypeInt = @"i";
10 | NSString *const MJPropertyTypeShort = @"s";
11 | NSString *const MJPropertyTypeFloat = @"f";
12 | NSString *const MJPropertyTypeDouble = @"d";
13 | NSString *const MJPropertyTypeLong = @"l";
14 | NSString *const MJPropertyTypeLongLong = @"q";
15 | NSString *const MJPropertyTypeChar = @"c";
16 | NSString *const MJPropertyTypeBOOL1 = @"c";
17 | NSString *const MJPropertyTypeBOOL2 = @"b";
18 | NSString *const MJPropertyTypePointer = @"*";
19 |
20 | NSString *const MJPropertyTypeIvar = @"^{objc_ivar=}";
21 | NSString *const MJPropertyTypeMethod = @"^{objc_method=}";
22 | NSString *const MJPropertyTypeBlock = @"@?";
23 | NSString *const MJPropertyTypeClass = @"#";
24 | NSString *const MJPropertyTypeSEL = @":";
25 | NSString *const MJPropertyTypeId = @"@";
26 |
27 | #endif
--------------------------------------------------------------------------------
/Benchmark/Vendor/MJExtension/MJFoundation.h:
--------------------------------------------------------------------------------
1 | //
2 | // MJFoundation.h
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 14/7/16.
6 | // Copyright (c) 2014年 小码哥. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MJFoundation : NSObject
12 | + (BOOL)isClassFromFoundation:(Class)c;
13 | @end
14 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/MJExtension/MJFoundation.m:
--------------------------------------------------------------------------------
1 | //
2 | // MJFoundation.m
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 14/7/16.
6 | // Copyright (c) 2014年 小码哥. All rights reserved.
7 | //
8 |
9 | #import "MJFoundation.h"
10 | #import "MJExtensionConst.h"
11 | #import
12 |
13 | static NSSet *foundationClasses_;
14 |
15 | @implementation MJFoundation
16 |
17 | + (NSSet *)foundationClasses
18 | {
19 | if (foundationClasses_ == nil) {
20 | // 集合中没有NSObject,因为几乎所有的类都是继承自NSObject,具体是不是NSObject需要特殊判断
21 | foundationClasses_ = [NSSet setWithObjects:
22 | [NSURL class],
23 | [NSDate class],
24 | [NSValue class],
25 | [NSData class],
26 | [NSError class],
27 | [NSArray class],
28 | [NSDictionary class],
29 | [NSString class],
30 | [NSAttributedString class], nil];
31 | }
32 | return foundationClasses_;
33 | }
34 |
35 | + (BOOL)isClassFromFoundation:(Class)c
36 | {
37 | if (c == [NSObject class] || c == [NSManagedObject class]) return YES;
38 |
39 | __block BOOL result = NO;
40 | [[self foundationClasses] enumerateObjectsUsingBlock:^(Class foundationClass, BOOL *stop) {
41 | if ([c isSubclassOfClass:foundationClass]) {
42 | result = YES;
43 | *stop = YES;
44 | }
45 | }];
46 | return result;
47 | }
48 | @end
49 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/MJExtension/MJProperty.h:
--------------------------------------------------------------------------------
1 | //
2 | // MJProperty.h
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 15/4/17.
6 | // Copyright (c) 2015年 小码哥. All rights reserved.
7 | // 包装一个成员属性
8 |
9 | #import
10 | #import
11 | #import "MJPropertyType.h"
12 | #import "MJPropertyKey.h"
13 |
14 | /**
15 | * 包装一个成员
16 | */
17 | @interface MJProperty : NSObject
18 | /** 成员属性 */
19 | @property (nonatomic, assign) objc_property_t property;
20 | /** 成员属性的名字 */
21 | @property (nonatomic, readonly) NSString *name;
22 |
23 | /** 成员属性的类型 */
24 | @property (nonatomic, readonly) MJPropertyType *type;
25 | /** 成员属性来源于哪个类(可能是父类) */
26 | @property (nonatomic, assign) Class srcClass;
27 |
28 | /**** 同一个成员属性 - 父类和子类的行为可能不一致(originKey、propertyKeys、objectClassInArray) ****/
29 | /** 设置最原始的key */
30 | - (void)setOriginKey:(id)originKey forClass:(Class)c;
31 | /** 对应着字典中的多级key(里面存放的数组,数组里面都是MJPropertyKey对象) */
32 | - (NSArray *)propertyKeysForClass:(Class)c;
33 |
34 | /** 模型数组中的模型类型 */
35 | - (void)setObjectClassInArray:(Class)objectClass forClass:(Class)c;
36 | - (Class)objectClassInArrayForClass:(Class)c;
37 | /**** 同一个成员变量 - 父类和子类的行为可能不一致(key、keys、objectClassInArray) ****/
38 |
39 | /**
40 | * 设置object的成员变量值
41 | */
42 | - (void)setValue:(id)value forObject:(id)object;
43 | /**
44 | * 得到object的成员属性值
45 | */
46 | - (id)valueForObject:(id)object;
47 |
48 | /**
49 | * 初始化
50 | */
51 | + (instancetype)cachedPropertyWithProperty:(objc_property_t)property;
52 |
53 | @end
54 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/MJExtension/MJPropertyKey.h:
--------------------------------------------------------------------------------
1 | //
2 | // MJPropertyKey.h
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 15/8/11.
6 | // Copyright (c) 2015年 小码哥. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | typedef enum {
12 | MJPropertyKeyTypeDictionary = 0, // 字典的key
13 | MJPropertyKeyTypeArray // 数组的key
14 | } MJPropertyKeyType;
15 |
16 | /**
17 | * 属性的key
18 | */
19 | @interface MJPropertyKey : NSObject
20 | /** key的名字 */
21 | @property (copy, nonatomic) NSString *name;
22 | /** key的种类,可能是@"10",可能是@"age" */
23 | @property (assign, nonatomic) MJPropertyKeyType type;
24 |
25 | /**
26 | * 根据当前的key,也就是name,从object(字典或者数组)中取值
27 | */
28 | - (id)valueInObject:(id)object;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/MJExtension/MJPropertyKey.m:
--------------------------------------------------------------------------------
1 | //
2 | // MJPropertyKey.m
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 15/8/11.
6 | // Copyright (c) 2015年 小码哥. All rights reserved.
7 | //
8 |
9 | #import "MJPropertyKey.h"
10 |
11 | @implementation MJPropertyKey
12 |
13 | - (id)valueInObject:(id)object
14 | {
15 | if ([object isKindOfClass:[NSDictionary class]] && self.type == MJPropertyKeyTypeDictionary) {
16 | return object[self.name];
17 | } else if ([object isKindOfClass:[NSArray class]] && self.type == MJPropertyKeyTypeArray) {
18 | NSArray *array = object;
19 | NSUInteger index = self.name.intValue;
20 | if (index < array.count) return array[index];
21 | return nil;
22 | }
23 | return nil;
24 | }
25 | @end
26 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/MJExtension/MJPropertyType.h:
--------------------------------------------------------------------------------
1 | //
2 | // MJPropertyType.h
3 | // MJExtension
4 | //
5 | // Created by mj on 14-1-15.
6 | // Copyright (c) 2014年 小码哥. All rights reserved.
7 | // 包装一种类型
8 |
9 | #import
10 |
11 | /**
12 | * 包装一种类型
13 | */
14 | @interface MJPropertyType : NSObject
15 | /** 类型标识符 */
16 | @property (nonatomic, copy) NSString *code;
17 |
18 | /** 是否为id类型 */
19 | @property (nonatomic, readonly, getter=isIdType) BOOL idType;
20 |
21 | /** 是否为基本数字类型:int、float等 */
22 | @property (nonatomic, readonly, getter=isNumberType) BOOL numberType;
23 |
24 | /** 是否为BOOL类型 */
25 | @property (nonatomic, readonly, getter=isBoolType) BOOL boolType;
26 |
27 | /** 对象类型(如果是基本数据类型,此值为nil) */
28 | @property (nonatomic, readonly) Class typeClass;
29 |
30 | /** 类型是否来自于Foundation框架,比如NSString、NSArray */
31 | @property (nonatomic, readonly, getter = isFromFoundation) BOOL fromFoundation;
32 | /** 类型是否不支持KVC */
33 | @property (nonatomic, readonly, getter = isKVCDisabled) BOOL KVCDisabled;
34 |
35 | /**
36 | * 获得缓存的类型对象
37 | */
38 | + (instancetype)cachedTypeWithCode:(NSString *)code;
39 | @end
--------------------------------------------------------------------------------
/Benchmark/Vendor/MJExtension/MJPropertyType.m:
--------------------------------------------------------------------------------
1 | //
2 | // MJPropertyType.m
3 | // MJExtension
4 | //
5 | // Created by mj on 14-1-15.
6 | // Copyright (c) 2014年 小码哥. All rights reserved.
7 | //
8 |
9 | #import "MJPropertyType.h"
10 | #import "MJExtension.h"
11 | #import "MJFoundation.h"
12 | #import "MJExtensionConst.h"
13 | #import "MJDictionaryCache.h"
14 |
15 | @implementation MJPropertyType
16 |
17 | + (instancetype)cachedTypeWithCode:(NSString *)code
18 | {
19 | MJExtensionAssertParamNotNil2(code, nil);
20 |
21 | static const char MJCachedTypesKey = '\0';
22 |
23 | MJPropertyType *type = [MJDictionaryCache objectForKey:code forDictId:&MJCachedTypesKey];
24 | if (type == nil) {
25 | type = [[self alloc] init];
26 | type.code = code;
27 | [MJDictionaryCache setObject:type forKey:code forDictId:&MJCachedTypesKey];
28 | }
29 | return type;
30 | }
31 |
32 | #pragma mark - 公共方法
33 | - (void)setCode:(NSString *)code
34 | {
35 | _code = code;
36 |
37 | MJExtensionAssertParamNotNil(code);
38 |
39 | if ([code isEqualToString:MJPropertyTypeId]) {
40 | _idType = YES;
41 | } else if (code.length == 0) {
42 | _KVCDisabled = YES;
43 | } else if (code.length > 3 && [code hasPrefix:@"@\""]) {
44 | // 去掉@"和",截取中间的类型名称
45 | _code = [code substringWithRange:NSMakeRange(2, code.length - 3)];
46 | _typeClass = NSClassFromString(_code);
47 | _fromFoundation = [MJFoundation isClassFromFoundation:_typeClass];
48 | _numberType = [_typeClass isSubclassOfClass:[NSNumber class]];
49 |
50 | } else if ([code isEqualToString:MJPropertyTypeSEL] ||
51 | [code isEqualToString:MJPropertyTypeIvar] ||
52 | [code isEqualToString:MJPropertyTypeMethod]) {
53 | _KVCDisabled = YES;
54 | }
55 |
56 | // 是否为数字类型
57 | NSString *lowerCode = _code.lowercaseString;
58 | NSArray *numberTypes = @[MJPropertyTypeInt, MJPropertyTypeShort, MJPropertyTypeBOOL1, MJPropertyTypeBOOL2, MJPropertyTypeFloat, MJPropertyTypeDouble, MJPropertyTypeLong, MJPropertyTypeLongLong, MJPropertyTypeChar];
59 | if ([numberTypes containsObject:lowerCode]) {
60 | _numberType = YES;
61 |
62 | if ([lowerCode isEqualToString:MJPropertyTypeBOOL1]
63 | || [lowerCode isEqualToString:MJPropertyTypeBOOL2]) {
64 | _boolType = YES;
65 | }
66 | }
67 | }
68 | @end
69 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/MJExtension/NSObject+MJClass.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+MJClass.h
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 15/8/11.
6 | // Copyright (c) 2015年 小码哥. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | /**
12 | * 遍历所有类的block(父类)
13 | */
14 | typedef void (^MJClassesEnumeration)(Class c, BOOL *stop);
15 |
16 | /** 这个数组中的属性名才会进行字典和模型的转换 */
17 | typedef NSArray * (^MJAllowedPropertyNames)();
18 | /** 这个数组中的属性名才会进行归档 */
19 | typedef NSArray * (^MJAllowedCodingPropertyNames)();
20 |
21 | /** 这个数组中的属性名将会被忽略:不进行字典和模型的转换 */
22 | typedef NSArray * (^MJIgnoredPropertyNames)();
23 | /** 这个数组中的属性名将会被忽略:不进行归档 */
24 | typedef NSArray * (^MJIgnoredCodingPropertyNames)();
25 |
26 | /**
27 | * 类相关的扩展
28 | */
29 | @interface NSObject (MJClass)
30 | /**
31 | * 遍历所有的类
32 | */
33 | + (void)mj_enumerateClasses:(MJClassesEnumeration)enumeration;
34 | + (void)mj_enumerateAllClasses:(MJClassesEnumeration)enumeration;
35 |
36 | #pragma mark - 属性白名单配置
37 | /**
38 | * 这个数组中的属性名才会进行字典和模型的转换
39 | *
40 | * @param allowedPropertyNames 这个数组中的属性名才会进行字典和模型的转换
41 | */
42 | + (void)mj_setupAllowedPropertyNames:(MJAllowedPropertyNames)allowedPropertyNames;
43 |
44 | /**
45 | * 这个数组中的属性名才会进行字典和模型的转换
46 | */
47 | + (NSMutableArray *)mj_totalAllowedPropertyNames;
48 |
49 | #pragma mark - 属性黑名单配置
50 | /**
51 | * 这个数组中的属性名将会被忽略:不进行字典和模型的转换
52 | *
53 | * @param ignoredPropertyNames 这个数组中的属性名将会被忽略:不进行字典和模型的转换
54 | */
55 | + (void)mj_setupIgnoredPropertyNames:(MJIgnoredPropertyNames)ignoredPropertyNames;
56 |
57 | /**
58 | * 这个数组中的属性名将会被忽略:不进行字典和模型的转换
59 | */
60 | + (NSMutableArray *)mj_totalIgnoredPropertyNames;
61 |
62 | #pragma mark - 归档属性白名单配置
63 | /**
64 | * 这个数组中的属性名才会进行归档
65 | *
66 | * @param allowedCodingPropertyNames 这个数组中的属性名才会进行归档
67 | */
68 | + (void)mj_setupAllowedCodingPropertyNames:(MJAllowedCodingPropertyNames)allowedCodingPropertyNames;
69 |
70 | /**
71 | * 这个数组中的属性名才会进行字典和模型的转换
72 | */
73 | + (NSMutableArray *)mj_totalAllowedCodingPropertyNames;
74 |
75 | #pragma mark - 归档属性黑名单配置
76 | /**
77 | * 这个数组中的属性名将会被忽略:不进行归档
78 | *
79 | * @param ignoredCodingPropertyNames 这个数组中的属性名将会被忽略:不进行归档
80 | */
81 | + (void)mj_setupIgnoredCodingPropertyNames:(MJIgnoredCodingPropertyNames)ignoredCodingPropertyNames;
82 |
83 | /**
84 | * 这个数组中的属性名将会被忽略:不进行归档
85 | */
86 | + (NSMutableArray *)mj_totalIgnoredCodingPropertyNames;
87 |
88 | #pragma mark - 内部使用
89 | + (void)mj_setupBlockReturnValue:(id (^)())block key:(const char *)key;
90 | @end
91 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/MJExtension/NSObject+MJCoding.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+MJCoding.h
3 | // MJExtension
4 | //
5 | // Created by mj on 14-1-15.
6 | // Copyright (c) 2014年 小码哥. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "MJExtensionConst.h"
11 |
12 | /**
13 | * Codeing协议
14 | */
15 | @protocol MJCoding
16 | @optional
17 | /**
18 | * 这个数组中的属性名才会进行归档
19 | */
20 | + (NSArray *)mj_allowedCodingPropertyNames;
21 | /**
22 | * 这个数组中的属性名将会被忽略:不进行归档
23 | */
24 | + (NSArray *)mj_ignoredCodingPropertyNames;
25 | @end
26 |
27 | @interface NSObject (MJCoding)
28 | /**
29 | * 解码(从文件中解析对象)
30 | */
31 | - (void)mj_decode:(NSCoder *)decoder;
32 | /**
33 | * 编码(将对象写入文件中)
34 | */
35 | - (void)mj_encode:(NSCoder *)encoder;
36 | @end
37 |
38 | /**
39 | 归档的实现
40 | */
41 | #define MJCodingImplementation \
42 | - (id)initWithCoder:(NSCoder *)decoder \
43 | { \
44 | if (self = [super init]) { \
45 | [self mj_decode:decoder]; \
46 | } \
47 | return self; \
48 | } \
49 | \
50 | - (void)encodeWithCoder:(NSCoder *)encoder \
51 | { \
52 | [self mj_encode:encoder]; \
53 | }
54 |
55 | #define MJExtensionCodingImplementation MJCodingImplementation
--------------------------------------------------------------------------------
/Benchmark/Vendor/MJExtension/NSObject+MJCoding.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+MJCoding.m
3 | // MJExtension
4 | //
5 | // Created by mj on 14-1-15.
6 | // Copyright (c) 2014年 小码哥. All rights reserved.
7 | //
8 |
9 | #import "NSObject+MJCoding.h"
10 | #import "NSObject+MJClass.h"
11 | #import "NSObject+MJProperty.h"
12 | #import "MJProperty.h"
13 |
14 | @implementation NSObject (MJCoding)
15 |
16 | - (void)mj_encode:(NSCoder *)encoder
17 | {
18 | Class clazz = [self class];
19 |
20 | NSArray *allowedCodingPropertyNames = [clazz mj_totalAllowedCodingPropertyNames];
21 | NSArray *ignoredCodingPropertyNames = [clazz mj_totalIgnoredCodingPropertyNames];
22 |
23 | [clazz mj_enumerateProperties:^(MJProperty *property, BOOL *stop) {
24 | // 检测是否被忽略
25 | if (allowedCodingPropertyNames.count && ![allowedCodingPropertyNames containsObject:property.name]) return;
26 | if ([ignoredCodingPropertyNames containsObject:property.name]) return;
27 |
28 | id value = [property valueForObject:self];
29 | if (value == nil) return;
30 | [encoder encodeObject:value forKey:property.name];
31 | }];
32 | }
33 |
34 | - (void)mj_decode:(NSCoder *)decoder
35 | {
36 | Class clazz = [self class];
37 |
38 | NSArray *allowedCodingPropertyNames = [clazz mj_totalAllowedCodingPropertyNames];
39 | NSArray *ignoredCodingPropertyNames = [clazz mj_totalIgnoredCodingPropertyNames];
40 |
41 | [clazz mj_enumerateProperties:^(MJProperty *property, BOOL *stop) {
42 | // 检测是否被忽略
43 | if (allowedCodingPropertyNames.count && ![allowedCodingPropertyNames containsObject:property.name]) return;
44 | if ([ignoredCodingPropertyNames containsObject:property.name]) return;
45 |
46 | id value = [decoder decodeObjectForKey:property.name];
47 | if (value == nil) { // 兼容以前的MJExtension版本
48 | value = [decoder decodeObjectForKey:[@"_" stringByAppendingString:property.name]];
49 | }
50 | if (value == nil) return;
51 | [property setValue:value forObject:self];
52 | }];
53 | }
54 | @end
55 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/MJExtension/NSObject+MJProperty.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+MJProperty.h
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 15/4/17.
6 | // Copyright (c) 2015年 小码哥. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "MJExtensionConst.h"
11 |
12 | @class MJProperty;
13 |
14 | /**
15 | * 遍历成员变量用的block
16 | *
17 | * @param property 成员的包装对象
18 | * @param stop YES代表停止遍历,NO代表继续遍历
19 | */
20 | typedef void (^MJPropertiesEnumeration)(MJProperty *property, BOOL *stop);
21 |
22 | /** 将属性名换为其他key去字典中取值 */
23 | typedef NSDictionary * (^MJReplacedKeyFromPropertyName)();
24 | typedef NSString * (^MJReplacedKeyFromPropertyName121)(NSString *propertyName);
25 | /** 数组中需要转换的模型类 */
26 | typedef NSDictionary * (^MJObjectClassInArray)();
27 | /** 用于过滤字典中的值 */
28 | typedef id (^MJNewValueFromOldValue)(id object, id oldValue, MJProperty *property);
29 |
30 | /**
31 | * 成员属性相关的扩展
32 | */
33 | @interface NSObject (MJProperty)
34 | #pragma mark - 遍历
35 | /**
36 | * 遍历所有的成员
37 | */
38 | + (void)mj_enumerateProperties:(MJPropertiesEnumeration)enumeration;
39 |
40 | #pragma mark - 新值配置
41 | /**
42 | * 用于过滤字典中的值
43 | *
44 | * @param newValueFormOldValue 用于过滤字典中的值
45 | */
46 | + (void)mj_setupNewValueFromOldValue:(MJNewValueFromOldValue)newValueFormOldValue;
47 | + (id)mj_getNewValueFromObject:(__unsafe_unretained id)object oldValue:(__unsafe_unretained id)oldValue property:(__unsafe_unretained MJProperty *)property;
48 |
49 | #pragma mark - key配置
50 | /**
51 | * 将属性名换为其他key去字典中取值
52 | *
53 | * @param replacedKeyFromPropertyName 将属性名换为其他key去字典中取值
54 | */
55 | + (void)mj_setupReplacedKeyFromPropertyName:(MJReplacedKeyFromPropertyName)replacedKeyFromPropertyName;
56 | /**
57 | * 将属性名换为其他key去字典中取值
58 | *
59 | * @param replacedKeyFromPropertyName121 将属性名换为其他key去字典中取值
60 | */
61 | + (void)mj_setupReplacedKeyFromPropertyName121:(MJReplacedKeyFromPropertyName121)replacedKeyFromPropertyName121;
62 |
63 | #pragma mark - array model class配置
64 | /**
65 | * 数组中需要转换的模型类
66 | *
67 | * @param objectClassInArray 数组中需要转换的模型类
68 | */
69 | + (void)mj_setupObjectClassInArray:(MJObjectClassInArray)objectClassInArray;
70 | @end
71 |
72 | @interface NSObject (MJPropertyDeprecated_v_2_5_16)
73 | + (void)enumerateProperties:(MJPropertiesEnumeration)enumeration MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***");
74 | + (void)setupNewValueFromOldValue:(MJNewValueFromOldValue)newValueFormOldValue MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***");
75 | + (id)getNewValueFromObject:(__unsafe_unretained id)object oldValue:(__unsafe_unretained id)oldValue property:(__unsafe_unretained MJProperty *)property MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***");
76 | + (void)setupReplacedKeyFromPropertyName:(MJReplacedKeyFromPropertyName)replacedKeyFromPropertyName MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***");
77 | + (void)setupReplacedKeyFromPropertyName121:(MJReplacedKeyFromPropertyName121)replacedKeyFromPropertyName121 MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***");
78 | + (void)setupObjectClassInArray:(MJObjectClassInArray)objectClassInArray MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***");
79 | @end
--------------------------------------------------------------------------------
/Benchmark/Vendor/MJExtension/NSString+MJExtension.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+MJExtension.h
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 15/6/7.
6 | // Copyright (c) 2015年 小码哥. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "MJExtensionConst.h"
11 |
12 | @interface NSString (MJExtension)
13 | /**
14 | * 驼峰转下划线(loveYou -> love_you)
15 | */
16 | - (NSString *)mj_underlineFromCamel;
17 | /**
18 | * 下划线转驼峰(love_you -> loveYou)
19 | */
20 | - (NSString *)mj_camelFromUnderline;
21 | /**
22 | * 首字母变大写
23 | */
24 | - (NSString *)mj_firstCharUpper;
25 | /**
26 | * 首字母变小写
27 | */
28 | - (NSString *)mj_firstCharLower;
29 |
30 | - (BOOL)mj_isPureInt;
31 |
32 | - (NSURL *)mj_url;
33 | @end
34 |
35 | @interface NSString (MJExtensionDeprecated_v_2_5_16)
36 | - (NSString *)underlineFromCamel MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***");
37 | - (NSString *)camelFromUnderline MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***");
38 | - (NSString *)firstCharUpper MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***");
39 | - (NSString *)firstCharLower MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***");
40 | - (BOOL)isPureInt MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***");
41 | - (NSURL *)url MJExtensionDeprecated("请在方法名前面加上mj_前缀,使用mj_***");
42 | @end
43 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/MJExtension/NSString+MJExtension.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+MJExtension.m
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 15/6/7.
6 | // Copyright (c) 2015年 小码哥. All rights reserved.
7 | //
8 |
9 | #import "NSString+MJExtension.h"
10 |
11 | @implementation NSString (MJExtension)
12 | - (NSString *)mj_underlineFromCamel
13 | {
14 | if (self.length == 0) return self;
15 | NSMutableString *string = [NSMutableString string];
16 | for (NSUInteger i = 0; i= 2) [string appendString:[cmp substringFromIndex:1]];
40 | } else {
41 | [string appendString:cmp];
42 | }
43 | }
44 | return string;
45 | }
46 |
47 | - (NSString *)mj_firstCharLower
48 | {
49 | if (self.length == 0) return self;
50 | NSMutableString *string = [NSMutableString string];
51 | [string appendString:[NSString stringWithFormat:@"%c", [self characterAtIndex:0]].lowercaseString];
52 | if (self.length >= 2) [string appendString:[self substringFromIndex:1]];
53 | return string;
54 | }
55 |
56 | - (NSString *)mj_firstCharUpper
57 | {
58 | if (self.length == 0) return self;
59 | NSMutableString *string = [NSMutableString string];
60 | [string appendString:[NSString stringWithFormat:@"%c", [self characterAtIndex:0]].uppercaseString];
61 | if (self.length >= 2) [string appendString:[self substringFromIndex:1]];
62 | return string;
63 | }
64 |
65 | - (BOOL)mj_isPureInt
66 | {
67 | NSScanner *scan = [NSScanner scannerWithString:self];
68 | int val;
69 | return [scan scanInt:&val] && [scan isAtEnd];
70 | }
71 |
72 | - (NSURL *)mj_url
73 | {
74 | // [self stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"!$&'()*+,-./:;=?@_~%#[]"]];
75 |
76 | return [NSURL URLWithString:(NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)self, (CFStringRef)@"!$&'()*+,-./:;=?@_~%#[]", NULL,kCFStringEncodingUTF8))];
77 | }
78 | @end
79 |
80 | @implementation NSString (MJExtensionDeprecated_v_2_5_16)
81 | - (NSString *)underlineFromCamel
82 | {
83 | return self.mj_underlineFromCamel;
84 | }
85 |
86 | - (NSString *)camelFromUnderline
87 | {
88 | return self.mj_camelFromUnderline;
89 | }
90 |
91 | - (NSString *)firstCharLower
92 | {
93 | return self.mj_firstCharLower;
94 | }
95 |
96 | - (NSString *)firstCharUpper
97 | {
98 | return self.mj_firstCharUpper;
99 | }
100 |
101 | - (BOOL)isPureInt
102 | {
103 | return self.mj_isPureInt;
104 | }
105 |
106 | - (NSURL *)url
107 | {
108 | return self.mj_url;
109 | }
110 | @end
111 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/Mantle/MTLReflection.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTLReflection.h
3 | // Mantle
4 | //
5 | // Created by Justin Spahr-Summers on 2013-03-12.
6 | // Copyright (c) 2013 GitHub. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | /// Creates a selector from a key and a constant string.
12 | ///
13 | /// key - The key to insert into the generated selector. This key should be in
14 | /// its natural case.
15 | /// suffix - A string to append to the key as part of the selector.
16 | ///
17 | /// Returns a selector, or NULL if the input strings cannot form a valid
18 | /// selector.
19 | SEL MTLSelectorWithKeyPattern(NSString *key, const char *suffix) __attribute__((pure, nonnull(1, 2)));
20 |
21 | /// Creates a selector from a key and a constant prefix and suffix.
22 | ///
23 | /// prefix - A string to prepend to the key as part of the selector.
24 | /// key - The key to insert into the generated selector. This key should be in
25 | /// its natural case, and will have its first letter capitalized when
26 | /// inserted.
27 | /// suffix - A string to append to the key as part of the selector.
28 | ///
29 | /// Returns a selector, or NULL if the input strings cannot form a valid
30 | /// selector.
31 | SEL MTLSelectorWithCapitalizedKeyPattern(const char *prefix, NSString *key, const char *suffix) __attribute__((pure, nonnull(1, 2, 3)));
32 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/Mantle/MTLReflection.m:
--------------------------------------------------------------------------------
1 | //
2 | // MTLReflection.m
3 | // Mantle
4 | //
5 | // Created by Justin Spahr-Summers on 2013-03-12.
6 | // Copyright (c) 2013 GitHub. All rights reserved.
7 | //
8 |
9 | #import "MTLReflection.h"
10 | #import
11 |
12 | SEL MTLSelectorWithKeyPattern(NSString *key, const char *suffix) {
13 | NSUInteger keyLength = [key maximumLengthOfBytesUsingEncoding:NSUTF8StringEncoding];
14 | NSUInteger suffixLength = strlen(suffix);
15 |
16 | char selector[keyLength + suffixLength + 1];
17 |
18 | BOOL success = [key getBytes:selector maxLength:keyLength usedLength:&keyLength encoding:NSUTF8StringEncoding options:0 range:NSMakeRange(0, key.length) remainingRange:NULL];
19 | if (!success) return NULL;
20 |
21 | memcpy(selector + keyLength, suffix, suffixLength);
22 | selector[keyLength + suffixLength] = '\0';
23 |
24 | return sel_registerName(selector);
25 | }
26 |
27 | SEL MTLSelectorWithCapitalizedKeyPattern(const char *prefix, NSString *key, const char *suffix) {
28 | NSUInteger prefixLength = strlen(prefix);
29 | NSUInteger suffixLength = strlen(suffix);
30 |
31 | NSString *initial = [key substringToIndex:1].uppercaseString;
32 | NSUInteger initialLength = [initial maximumLengthOfBytesUsingEncoding:NSUTF8StringEncoding];
33 |
34 | NSString *rest = [key substringFromIndex:1];
35 | NSUInteger restLength = [rest maximumLengthOfBytesUsingEncoding:NSUTF8StringEncoding];
36 |
37 | char selector[prefixLength + initialLength + restLength + suffixLength + 1];
38 | memcpy(selector, prefix, prefixLength);
39 |
40 | BOOL success = [initial getBytes:selector + prefixLength maxLength:initialLength usedLength:&initialLength encoding:NSUTF8StringEncoding options:0 range:NSMakeRange(0, initial.length) remainingRange:NULL];
41 | if (!success) return NULL;
42 |
43 | success = [rest getBytes:selector + prefixLength + initialLength maxLength:restLength usedLength:&restLength encoding:NSUTF8StringEncoding options:0 range:NSMakeRange(0, rest.length) remainingRange:NULL];
44 | if (!success) return NULL;
45 |
46 | memcpy(selector + prefixLength + initialLength + restLength, suffix, suffixLength);
47 | selector[prefixLength + initialLength + restLength + suffixLength] = '\0';
48 |
49 | return sel_registerName(selector);
50 | }
51 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/Mantle/MTLTransformerErrorHandling.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTLTransformerErrorHandling.h
3 | // Mantle
4 | //
5 | // Created by Robert Böhnke on 10/6/13.
6 | // Copyright (c) 2013 GitHub. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | /// The domain for errors originating from the MTLTransformerErrorHandling
12 | /// protocol.
13 | ///
14 | /// Transformers conforming to this protocol are expected to use this error
15 | /// domain if the transformation fails.
16 | extern NSString * const MTLTransformerErrorHandlingErrorDomain;
17 |
18 | /// Used to indicate that the input value was illegal.
19 | ///
20 | /// Transformers conforming to this protocol are expected to use this error code
21 | /// if the transformation fails due to an invalid input value.
22 | extern const NSInteger MTLTransformerErrorHandlingErrorInvalidInput;
23 |
24 | /// Associated with the invalid input value.
25 | ///
26 | /// Transformers conforming to this protocol are expected to associate this key
27 | /// with the invalid input in the userInfo dictionary.
28 | extern NSString * const MTLTransformerErrorHandlingInputValueErrorKey;
29 |
30 | /// This protocol can be implemented by NSValueTransformer subclasses to
31 | /// communicate errors that occur during transformation.
32 | @protocol MTLTransformerErrorHandling
33 | @required
34 |
35 | /// Transforms a value, returning any error that occurred during transformation.
36 | ///
37 | /// value - The value to transform.
38 | /// success - If not NULL, this will be set to a boolean indicating whether the
39 | /// transformation was successful.
40 | /// error - If not NULL, this may be set to an error that occurs during
41 | /// transforming the value.
42 | ///
43 | /// Returns the result of the transformation which may be nil. Clients should
44 | /// inspect the success parameter to decide how to proceed with the result.
45 | - (id)transformedValue:(id)value success:(BOOL *)success error:(NSError **)error;
46 |
47 | @optional
48 |
49 | /// Reverse-transforms a value, returning any error that occurred during
50 | /// transformation.
51 | ///
52 | /// Transformers conforming to this protocol are expected to implemented this
53 | /// method if they support reverse transformation.
54 | ///
55 | /// value - The value to transform.
56 | /// success - If not NULL, this will be set to a boolean indicating whether the
57 | /// transformation was successful.
58 | /// error - If not NULL, this may be set to an error that occurs during
59 | /// transforming the value.
60 | ///
61 | /// Returns the result of the reverse transformation which may be nil. Clients
62 | /// should inspect the success parameter to decide how to proceed with the
63 | /// result.
64 | - (id)reverseTransformedValue:(id)value success:(BOOL *)success error:(NSError **)error;
65 |
66 | @end
67 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/Mantle/MTLTransformerErrorHandling.m:
--------------------------------------------------------------------------------
1 | //
2 | // MTLTransformerErrorHandling.h
3 | // Mantle
4 | //
5 | // Created by Robert Böhnke on 10/6/13.
6 | // Copyright (c) 2013 GitHub. All rights reserved.
7 | //
8 |
9 | #import "MTLTransformerErrorHandling.h"
10 |
11 | NSString * const MTLTransformerErrorHandlingErrorDomain = @"MTLTransformerErrorHandlingErrorDomain";
12 |
13 | const NSInteger MTLTransformerErrorHandlingErrorInvalidInput = 1;
14 |
15 | NSString * const MTLTransformerErrorHandlingInputValueErrorKey = @"MTLTransformerErrorHandlingInputValueErrorKey";
16 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/Mantle/MTLValueTransformer.h:
--------------------------------------------------------------------------------
1 | //
2 | // MTLValueTransformer.h
3 | // Mantle
4 | //
5 | // Created by Justin Spahr-Summers on 2012-09-11.
6 | // Copyright (c) 2012 GitHub. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "MTLTransformerErrorHandling.h"
12 |
13 | /// A block that represents a transformation.
14 | ///
15 | /// value - The value to transform.
16 | /// success - The block must set this parameter to indicate whether the
17 | /// transformation was successful.
18 | /// MTLValueTransformer will always call this block with *success
19 | /// initialized to YES.
20 | /// error - If not NULL, this may be set to an error that occurs during
21 | /// transforming the value.
22 | ///
23 | /// Returns the result of the transformation, which may be nil.
24 | typedef id (^MTLValueTransformerBlock)(id value, BOOL *success, NSError **error);
25 |
26 | ///
27 | /// A value transformer supporting block-based transformation.
28 | ///
29 | @interface MTLValueTransformer : NSValueTransformer
30 |
31 | /// Returns a transformer which transforms values using the given block. Reverse
32 | /// transformations will not be allowed.
33 | + (instancetype)transformerUsingForwardBlock:(MTLValueTransformerBlock)transformation;
34 |
35 | /// Returns a transformer which transforms values using the given block, for
36 | /// forward or reverse transformations.
37 | + (instancetype)transformerUsingReversibleBlock:(MTLValueTransformerBlock)transformation;
38 |
39 | /// Returns a transformer which transforms values using the given blocks.
40 | + (instancetype)transformerUsingForwardBlock:(MTLValueTransformerBlock)forwardTransformation reverseBlock:(MTLValueTransformerBlock)reverseTransformation;
41 |
42 | @end
43 |
44 | @interface MTLValueTransformer (Deprecated)
45 |
46 | + (NSValueTransformer *)transformerWithBlock:(id (^)(id))transformationBlock __attribute__((deprecated("Replaced by +transformerUsingForwardBlock:")));
47 |
48 | + (NSValueTransformer *)reversibleTransformerWithBlock:(id (^)(id))transformationBlock __attribute__((deprecated("Replaced by +transformerUsingReversibleBlock:")));
49 |
50 | + (NSValueTransformer *)reversibleTransformerWithForwardBlock:(id (^)(id))forwardBlock reverseBlock:(id (^)(id))reverseBlock __attribute__((deprecated("Replaced by +transformerUsingForwardBlock:reverseBlock:")));
51 |
52 | @end
53 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/Mantle/Mantle.h:
--------------------------------------------------------------------------------
1 | //
2 | // Mantle.h
3 | // Mantle
4 | //
5 | // Created by Justin Spahr-Summers on 2012-09-04.
6 | // Copyright (c) 2012 GitHub. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //! Project version number for Mantle.
12 | FOUNDATION_EXPORT double MantleVersionNumber;
13 |
14 | //! Project version string for Mantle.
15 | FOUNDATION_EXPORT const unsigned char MantleVersionString[];
16 |
17 | #import "MTLJSONAdapter.h"
18 | #import "MTLModel.h"
19 | #import "MTLModel+NSCoding.h"
20 | #import "MTLValueTransformer.h"
21 | #import "MTLTransformerErrorHandling.h"
22 | #import "NSArray+MTLManipulationAdditions.h"
23 | #import "NSDictionary+MTLManipulationAdditions.h"
24 | #import "NSDictionary+MTLMappingAdditions.h"
25 | #import "NSObject+MTLComparisonAdditions.h"
26 | #import "NSValueTransformer+MTLInversionAdditions.h"
27 | #import "NSValueTransformer+MTLPredefinedTransformerAdditions.h"
28 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/Mantle/NSArray+MTLManipulationAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSArray+MTLManipulationAdditions.h
3 | // Mantle
4 | //
5 | // Created by Josh Abernathy on 9/19/12.
6 | // Copyright (c) 2012 GitHub. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSArray (MTLManipulationAdditions)
12 |
13 | /// The first object in the array or nil if the array is empty.
14 | /// Forwards to `firstObject` which has been first declared in iOS7, but works with iOS4/10.6.
15 | @property (nonatomic, readonly, strong) id mtl_firstObject;
16 |
17 | /// Returns a new array without all instances of the given object.
18 | - (NSArray *)mtl_arrayByRemovingObject:(id)object;
19 |
20 | /// Returns a new array without the first object. If the array is empty, it
21 | /// returns the empty array.
22 | - (NSArray *)mtl_arrayByRemovingFirstObject;
23 |
24 | /// Returns a new array without the last object. If the array is empty, it
25 | /// returns the empty array.
26 | - (NSArray *)mtl_arrayByRemovingLastObject;
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/Mantle/NSArray+MTLManipulationAdditions.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSArray+MTLManipulationAdditions.m
3 | // Mantle
4 | //
5 | // Created by Josh Abernathy on 9/19/12.
6 | // Copyright (c) 2012 GitHub. All rights reserved.
7 | //
8 |
9 | #import "NSArray+MTLManipulationAdditions.h"
10 |
11 | @interface NSArray (MTLDeclarations)
12 |
13 | // This declaration is needed so Mantle can be compiled with SDK 6 / 10.8.
14 | - (id)firstObject;
15 |
16 | @end
17 |
18 | @implementation NSArray (MTLManipulationAdditions)
19 |
20 | - (id)mtl_firstObject {
21 | return self.firstObject;
22 | }
23 |
24 | - (instancetype)mtl_arrayByRemovingObject:(id)object {
25 | NSMutableArray *result = [self mutableCopy];
26 | [result removeObject:object];
27 | return result;
28 | }
29 |
30 | - (instancetype)mtl_arrayByRemovingFirstObject {
31 | if (self.count == 0) return self;
32 |
33 | return [self subarrayWithRange:NSMakeRange(1, self.count - 1)];
34 | }
35 |
36 | - (instancetype)mtl_arrayByRemovingLastObject {
37 | if (self.count == 0) return self;
38 |
39 | return [self subarrayWithRange:NSMakeRange(0, self.count - 1)];
40 | }
41 |
42 | @end
43 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/Mantle/NSDictionary+MTLJSONKeyPath.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSDictionary+MTLJSONKeyPath.h
3 | // Mantle
4 | //
5 | // Created by Robert Böhnke on 19/03/14.
6 | // Copyright (c) 2014 GitHub. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSDictionary (MTLJSONKeyPath)
12 |
13 | /// Looks up the value of a key path in the receiver.
14 | ///
15 | /// JSONKeyPath - The key path that should be resolved. Every element along this
16 | /// key path needs to be an instance of NSDictionary for the
17 | /// resolving to be successful.
18 | /// success - If not NULL, this will be set to a boolean indicating whether
19 | /// the key path was resolved successfully.
20 | /// error - If not NULL, this may be set to an error that occurs during
21 | /// resolving the value.
22 | ///
23 | /// Returns the value for the key path which may be nil. Clients should inspect
24 | /// the success parameter to decide how to proceed with the result.
25 | - (id)mtl_valueForJSONKeyPath:(NSString *)JSONKeyPath success:(BOOL *)success error:(NSError **)error;
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/Mantle/NSDictionary+MTLJSONKeyPath.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSDictionary+MTLJSONKeyPath.m
3 | // Mantle
4 | //
5 | // Created by Robert Böhnke on 19/03/14.
6 | // Copyright (c) 2014 GitHub. All rights reserved.
7 | //
8 |
9 | #import "NSDictionary+MTLJSONKeyPath.h"
10 |
11 | #import "MTLJSONAdapter.h"
12 |
13 | @implementation NSDictionary (MTLJSONKeyPath)
14 |
15 | - (id)mtl_valueForJSONKeyPath:(NSString *)JSONKeyPath success:(BOOL *)success error:(NSError **)error {
16 | NSArray *components = [JSONKeyPath componentsSeparatedByString:@"."];
17 |
18 | id result = self;
19 | for (NSString *component in components) {
20 | // Check the result before resolving the key path component to not
21 | // affect the last value of the path.
22 | if (result == nil || result == NSNull.null) break;
23 |
24 | if (![result isKindOfClass:NSDictionary.class]) {
25 | if (error != NULL) {
26 | NSDictionary *userInfo = @{
27 | NSLocalizedDescriptionKey: NSLocalizedString(@"Invalid JSON dictionary", @""),
28 | NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:NSLocalizedString(@"JSON key path %1$@ could not resolved because an incompatible JSON dictionary was supplied: \"%2$@\"", @""), JSONKeyPath, self]
29 | };
30 |
31 | *error = [NSError errorWithDomain:MTLJSONAdapterErrorDomain code:MTLJSONAdapterErrorInvalidJSONDictionary userInfo:userInfo];
32 | }
33 |
34 | if (success != NULL) *success = NO;
35 |
36 | return nil;
37 | }
38 |
39 | result = result[component];
40 | }
41 |
42 | if (success != NULL) *success = YES;
43 |
44 | return result;
45 | }
46 |
47 | @end
48 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/Mantle/NSDictionary+MTLManipulationAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSDictionary+MTLManipulationAdditions.h
3 | // Mantle
4 | //
5 | // Created by Justin Spahr-Summers on 2012-09-24.
6 | // Copyright (c) 2012 GitHub. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSDictionary (MTLManipulationAdditions)
12 |
13 | /// Merges the keys and values from the given dictionary into the receiver. If
14 | /// both the receiver and `dictionary` have a given key, the value from
15 | /// `dictionary` is used.
16 | ///
17 | /// Returns a new dictionary containing the entries of the receiver combined with
18 | /// those of `dictionary`.
19 | - (NSDictionary *)mtl_dictionaryByAddingEntriesFromDictionary:(NSDictionary *)dictionary;
20 |
21 | /// Creates a new dictionary with all the entries for the given keys removed from
22 | /// the receiver.
23 | - (NSDictionary *)mtl_dictionaryByRemovingValuesForKeys:(NSArray *)keys;
24 |
25 | @end
26 |
27 | @interface NSDictionary (MTLManipulationAdditions_Deprecated)
28 |
29 | - (NSDictionary *)mtl_dictionaryByRemovingEntriesWithKeys:(NSSet *)keys __attribute__((deprecated("Replaced by -mtl_dictionaryByRemovingValuesForKeys:")));
30 |
31 | @end
32 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/Mantle/NSDictionary+MTLManipulationAdditions.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSDictionary+MTLManipulationAdditions.m
3 | // Mantle
4 | //
5 | // Created by Justin Spahr-Summers on 2012-09-24.
6 | // Copyright (c) 2012 GitHub. All rights reserved.
7 | //
8 |
9 | #import "NSDictionary+MTLManipulationAdditions.h"
10 |
11 | @implementation NSDictionary (MTLManipulationAdditions)
12 |
13 | - (NSDictionary *)mtl_dictionaryByAddingEntriesFromDictionary:(NSDictionary *)dictionary {
14 | NSMutableDictionary *result = [self mutableCopy];
15 | [result addEntriesFromDictionary:dictionary];
16 | return result;
17 | }
18 |
19 | - (NSDictionary *)mtl_dictionaryByRemovingValuesForKeys:(NSArray *)keys {
20 | NSMutableDictionary *result = [self mutableCopy];
21 | [result removeObjectsForKeys:keys];
22 | return result;
23 | }
24 |
25 | @end
26 |
27 | @implementation NSDictionary (MTLManipulationAdditions_Deprecated)
28 |
29 | #pragma clang diagnostic push
30 | #pragma clang diagnostic ignored "-Wdeprecated"
31 |
32 | - (NSDictionary *)mtl_dictionaryByRemovingEntriesWithKeys:(NSSet *)keys {
33 | return [self mtl_dictionaryByRemovingValuesForKeys:keys.allObjects];
34 | }
35 |
36 | #pragma clang diagnostic pop
37 |
38 | @end
39 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/Mantle/NSDictionary+MTLMappingAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSDictionary+MTLMappingAdditions.h
3 | // Mantle
4 | //
5 | // Created by Robert Böhnke on 10/31/13.
6 | // Copyright (c) 2013 GitHub. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSDictionary (MTLMappingAdditions)
12 |
13 | /// Creates an identity mapping for serialization.
14 | ///
15 | /// class - A subclass of MTLModel.
16 | ///
17 | /// Returns a dictionary that maps all properties of the given class to
18 | /// themselves.
19 | + (NSDictionary *)mtl_identityPropertyMapWithModel:(Class)modelClass;
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/Mantle/NSDictionary+MTLMappingAdditions.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSDictionary+MTLMappingAdditions.m
3 | // Mantle
4 | //
5 | // Created by Robert Böhnke on 10/31/13.
6 | // Copyright (c) 2013 GitHub. All rights reserved.
7 | //
8 |
9 | #import "MTLModel.h"
10 |
11 | #import "NSDictionary+MTLMappingAdditions.h"
12 |
13 | @implementation NSDictionary (MTLMappingAdditions)
14 |
15 | + (NSDictionary *)mtl_identityPropertyMapWithModel:(Class)modelClass {
16 | NSCParameterAssert([modelClass isSubclassOfClass:MTLModel.class]);
17 |
18 | NSArray *propertyKeys = [modelClass propertyKeys].allObjects;
19 |
20 | return [NSDictionary dictionaryWithObjects:propertyKeys forKeys:propertyKeys];
21 | }
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/Mantle/NSError+MTLModelException.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSError+MTLModelException.h
3 | // Mantle
4 | //
5 | // Created by Robert Böhnke on 7/6/13.
6 | // Copyright (c) 2013 GitHub. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSError (MTLModelException)
12 |
13 | /// Creates a new error for an exception that occurred during updating an
14 | /// MTLModel.
15 | ///
16 | /// exception - The exception that was thrown while updating the model.
17 | /// This argument must not be nil.
18 | ///
19 | /// Returns an error that takes its localized description and failure reason
20 | /// from the exception.
21 | + (instancetype)mtl_modelErrorWithException:(NSException *)exception;
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/Mantle/NSError+MTLModelException.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSError+MTLModelException.m
3 | // Mantle
4 | //
5 | // Created by Robert Böhnke on 7/6/13.
6 | // Copyright (c) 2013 GitHub. All rights reserved.
7 | //
8 |
9 | #import "MTLModel.h"
10 |
11 | #import "NSError+MTLModelException.h"
12 |
13 | // The domain for errors originating from MTLModel.
14 | static NSString * const MTLModelErrorDomain = @"MTLModelErrorDomain";
15 |
16 | // An exception was thrown and caught.
17 | static const NSInteger MTLModelErrorExceptionThrown = 1;
18 |
19 | // Associated with the NSException that was caught.
20 | static NSString * const MTLModelThrownExceptionErrorKey = @"MTLModelThrownException";
21 |
22 | @implementation NSError (MTLModelException)
23 |
24 | + (instancetype)mtl_modelErrorWithException:(NSException *)exception {
25 | NSParameterAssert(exception != nil);
26 |
27 | NSDictionary *userInfo = @{
28 | NSLocalizedDescriptionKey: exception.description,
29 | NSLocalizedFailureReasonErrorKey: exception.reason,
30 | MTLModelThrownExceptionErrorKey: exception
31 | };
32 |
33 | return [NSError errorWithDomain:MTLModelErrorDomain code:MTLModelErrorExceptionThrown userInfo:userInfo];
34 | }
35 |
36 | @end
37 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/Mantle/NSObject+MTLComparisonAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+MTLComparisonAdditions.h
3 | // Mantle
4 | //
5 | // Created by Josh Vera on 10/26/12.
6 | // Copyright (c) 2012 GitHub. All rights reserved.
7 | //
8 | // Portions copyright (c) 2011 Bitswift. All rights reserved.
9 | // See the LICENSE file for more information.
10 | //
11 |
12 | #import
13 |
14 | /// Returns whether both objects are identical or equal via -isEqual:
15 | BOOL MTLEqualObjects(id obj1, id obj2);
16 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/Mantle/NSObject+MTLComparisonAdditions.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+MTLComparisonAdditions.m
3 | // Mantle
4 | //
5 | // Created by Josh Vera on 10/26/12.
6 | // Copyright (c) 2012 GitHub. All rights reserved.
7 | //
8 | // Portions copyright (c) 2011 Bitswift. All rights reserved.
9 | // See the LICENSE file for more information.
10 | //
11 |
12 | #import "NSObject+MTLComparisonAdditions.h"
13 |
14 | BOOL MTLEqualObjects(id obj1, id obj2) {
15 | return (obj1 == obj2 || [obj1 isEqual:obj2]);
16 | }
17 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/Mantle/NSValueTransformer+MTLInversionAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSValueTransformer+MTLInversionAdditions.h
3 | // Mantle
4 | //
5 | // Created by Justin Spahr-Summers on 2013-05-18.
6 | // Copyright (c) 2013 GitHub. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSValueTransformer (MTLInversionAdditions)
12 |
13 | /// Flips the direction of the receiver's transformation, such that
14 | /// -transformedValue: will become -reverseTransformedValue:, and vice-versa.
15 | ///
16 | /// The receiver must allow reverse transformation.
17 | ///
18 | /// Returns an inverted transformer.
19 | - (NSValueTransformer *)mtl_invertedTransformer;
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/Mantle/NSValueTransformer+MTLInversionAdditions.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSValueTransformer+MTLInversionAdditions.m
3 | // Mantle
4 | //
5 | // Created by Justin Spahr-Summers on 2013-05-18.
6 | // Copyright (c) 2013 GitHub. All rights reserved.
7 | //
8 |
9 | #import "NSValueTransformer+MTLInversionAdditions.h"
10 | #import "MTLTransformerErrorHandling.h"
11 | #import "MTLValueTransformer.h"
12 |
13 | @implementation NSValueTransformer (MTLInversionAdditions)
14 |
15 | - (NSValueTransformer *)mtl_invertedTransformer {
16 | NSParameterAssert(self.class.allowsReverseTransformation);
17 |
18 | if ([self conformsToProtocol:@protocol(MTLTransformerErrorHandling)]) {
19 | NSParameterAssert([self respondsToSelector:@selector(reverseTransformedValue:success:error:)]);
20 |
21 | id errorHandlingSelf = (id)self;
22 |
23 | return [MTLValueTransformer transformerUsingForwardBlock:^(id value, BOOL *success, NSError **error) {
24 | return [errorHandlingSelf reverseTransformedValue:value success:success error:error];
25 | } reverseBlock:^(id value, BOOL *success, NSError **error) {
26 | return [errorHandlingSelf transformedValue:value success:success error:error];
27 | }];
28 | } else {
29 | return [MTLValueTransformer transformerUsingForwardBlock:^(id value, BOOL *success, NSError **error) {
30 | return [self reverseTransformedValue:value];
31 | } reverseBlock:^(id value, BOOL *success, NSError **error) {
32 | return [self transformedValue:value];
33 | }];
34 | }
35 | }
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/Mantle/NSValueTransformer+MTLPredefinedTransformerAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSValueTransformer+MTLPredefinedTransformerAdditions.h
3 | // Mantle
4 | //
5 | // Created by Justin Spahr-Summers on 2012-09-27.
6 | // Copyright (c) 2012 GitHub. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "MTLTransformerErrorHandling.h"
12 |
13 | /// The name for a value transformer that converts strings into URLs and back.
14 | extern NSString * const MTLURLValueTransformerName;
15 |
16 | /// Ensure an NSNumber is backed by __NSCFBoolean/CFBooleanRef
17 | ///
18 | /// NSJSONSerialization, and likely other serialization libraries, ordinarily
19 | /// serialize NSNumbers as numbers, and thus booleans would be serialized as
20 | /// 0/1. The exception is when the NSNumber is backed by __NSCFBoolean, which,
21 | /// though very much an implementation detail, is detected and serialized as a
22 | /// proper boolean.
23 | extern NSString * const MTLBooleanValueTransformerName;
24 |
25 | @interface NSValueTransformer (MTLPredefinedTransformerAdditions)
26 |
27 | /// An optionally reversible transformer which applies the given transformer to
28 | /// each element of an array.
29 | ///
30 | /// transformer - The transformer to apply to each element. If the transformer
31 | /// is reversible, the transformer returned by this method will be
32 | /// reversible. This argument must not be nil.
33 | ///
34 | /// Returns a transformer which applies a transformation to each element of an
35 | /// array.
36 | + (NSValueTransformer *)mtl_arrayMappingTransformerWithTransformer:(NSValueTransformer *)transformer;
37 |
38 | /// A reversible value transformer to transform between the keys and objects of a
39 | /// dictionary.
40 | ///
41 | /// dictionary - The dictionary whose keys and values should be
42 | /// transformed between. This argument must not be nil.
43 | /// defaultValue - The result to fall back to, in case no key matching the
44 | /// input value was found during a forward transformation.
45 | /// reverseDefaultValue - The result to fall back to, in case no value matching
46 | /// the input value was found during a reverse
47 | /// transformation.
48 | ///
49 | /// Can for example be used for transforming between enum values and their string
50 | /// representation.
51 | ///
52 | /// NSValueTransformer *valueTransformer = [NSValueTransformer mtl_valueMappingTransformerWithDictionary:@{
53 | /// @"foo": @(EnumDataTypeFoo),
54 | /// @"bar": @(EnumDataTypeBar),
55 | /// } defaultValue: @(EnumDataTypeUndefined) reverseDefaultValue: @"undefined"];
56 | ///
57 | /// Returns a transformer which will map from keys to objects for forward
58 | /// transformations, and from objects to keys for reverse transformations.
59 | + (NSValueTransformer *)mtl_valueMappingTransformerWithDictionary:(NSDictionary *)dictionary defaultValue:(id)defaultValue reverseDefaultValue:(id)reverseDefaultValue;
60 |
61 | /// Returns a value transformer created by calling
62 | /// `+mtl_valueMappingTransformerWithDictionary:defaultValue:reverseDefaultValue:`
63 | /// with a default value of `nil` and a reverse default value of `nil`.
64 | + (NSValueTransformer *)mtl_valueMappingTransformerWithDictionary:(NSDictionary *)dictionary;
65 |
66 | /// A value transformer that errors if the transformed value are not of the given
67 | /// class.
68 | ///
69 | /// class - The expected class. This argument must not be nil.
70 | ///
71 | /// Returns a transformer which will return an error if the transformed in value
72 | /// is not a member of class. Otherwise, the value is simply passed through.
73 | + (NSValueTransformer *)mtl_validatingTransformerForClass:(Class)modelClass;
74 |
75 | + (NSValueTransformer *)mtl_JSONDictionaryTransformerWithModelClass:(Class)modelClass __attribute__((deprecated("Replaced by +[MTLJSONAdapter dictionaryTransformerWithModelClass:]")));
76 |
77 | + (NSValueTransformer *)mtl_JSONArrayTransformerWithModelClass:(Class)modelClass __attribute__((deprecated("Replaced by +[MTLJSONAdapter arrayTransformerWithModelClass:]")));
78 |
79 | @end
80 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/Mantle/extobjc/EXTKeyPathCoding.h:
--------------------------------------------------------------------------------
1 | //
2 | // EXTKeyPathCoding.h
3 | // extobjc
4 | //
5 | // Created by Justin Spahr-Summers on 19.06.12.
6 | // Copyright (C) 2012 Justin Spahr-Summers.
7 | // Released under the MIT license.
8 | //
9 |
10 | #import
11 | #import "metamacros.h"
12 |
13 | /**
14 | * \@keypath allows compile-time verification of key paths. Given a real object
15 | * receiver and key path:
16 | *
17 | * @code
18 |
19 | NSString *UTF8StringPath = @keypath(str.lowercaseString.UTF8String);
20 | // => @"lowercaseString.UTF8String"
21 |
22 | NSString *versionPath = @keypath(NSObject, version);
23 | // => @"version"
24 |
25 | NSString *lowercaseStringPath = @keypath(NSString.new, lowercaseString);
26 | // => @"lowercaseString"
27 |
28 | * @endcode
29 | *
30 | * ... the macro returns an \c NSString containing all but the first path
31 | * component or argument (e.g., @"lowercaseString.UTF8String", @"version").
32 | *
33 | * In addition to simply creating a key path, this macro ensures that the key
34 | * path is valid at compile-time (causing a syntax error if not), and supports
35 | * refactoring, such that changing the name of the property will also update any
36 | * uses of \@keypath.
37 | */
38 | #define keypath(...) \
39 | metamacro_if_eq(1, metamacro_argcount(__VA_ARGS__))(keypath1(__VA_ARGS__))(keypath2(__VA_ARGS__))
40 |
41 | #define keypath1(PATH) \
42 | (((void)(NO && ((void)PATH, NO)), strchr(# PATH, '.') + 1))
43 |
44 | #define keypath2(OBJ, PATH) \
45 | (((void)(NO && ((void)OBJ.PATH, NO)), # PATH))
46 |
47 | /**
48 | * \@collectionKeypath allows compile-time verification of key paths across collections NSArray/NSSet etc. Given a real object
49 | * receiver, collection object receiver and related keypaths:
50 | *
51 | * @code
52 |
53 | NSString *employeesFirstNamePath = @collectionKeypath(department.employees, Employee.new, firstName)
54 | // => @"employees.firstName"
55 |
56 | NSString *employeesFirstNamePath = @collectionKeypath(Department.new, employees, Employee.new, firstName)
57 | // => @"employees.firstName"
58 |
59 | * @endcode
60 | *
61 | */
62 | #define collectionKeypath(...) \
63 | metamacro_if_eq(3, metamacro_argcount(__VA_ARGS__))(collectionKeypath3(__VA_ARGS__))(collectionKeypath4(__VA_ARGS__))
64 |
65 | #define collectionKeypath3(PATH, COLLECTION_OBJECT, COLLECTION_PATH) ([[NSString stringWithFormat:@"%s.%s",keypath(PATH), keypath(COLLECTION_OBJECT, COLLECTION_PATH)] UTF8String])
66 |
67 | #define collectionKeypath4(OBJ, PATH, COLLECTION_OBJECT, COLLECTION_PATH) ([[NSString stringWithFormat:@"%s.%s",keypath(OBJ, PATH), keypath(COLLECTION_OBJECT, COLLECTION_PATH)] UTF8String])
68 |
69 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/Mantle/extobjc/EXTRuntimeExtensions.h:
--------------------------------------------------------------------------------
1 | //
2 | // EXTRuntimeExtensions.h
3 | // extobjc
4 | //
5 | // Created by Justin Spahr-Summers on 2011-03-05.
6 | // Copyright (C) 2012 Justin Spahr-Summers.
7 | // Released under the MIT license.
8 | //
9 |
10 | #import
11 |
12 | /**
13 | * Describes the memory management policy of a property.
14 | */
15 | typedef enum {
16 | /**
17 | * The value is assigned.
18 | */
19 | mtl_propertyMemoryManagementPolicyAssign = 0,
20 |
21 | /**
22 | * The value is retained.
23 | */
24 | mtl_propertyMemoryManagementPolicyRetain,
25 |
26 | /**
27 | * The value is copied.
28 | */
29 | mtl_propertyMemoryManagementPolicyCopy
30 | } mtl_propertyMemoryManagementPolicy;
31 |
32 | /**
33 | * Describes the attributes and type information of a property.
34 | */
35 | typedef struct {
36 | /**
37 | * Whether this property was declared with the \c readonly attribute.
38 | */
39 | BOOL readonly;
40 |
41 | /**
42 | * Whether this property was declared with the \c nonatomic attribute.
43 | */
44 | BOOL nonatomic;
45 |
46 | /**
47 | * Whether the property is a weak reference.
48 | */
49 | BOOL weak;
50 |
51 | /**
52 | * Whether the property is eligible for garbage collection.
53 | */
54 | BOOL canBeCollected;
55 |
56 | /**
57 | * Whether this property is defined with \c \@dynamic.
58 | */
59 | BOOL dynamic;
60 |
61 | /**
62 | * The memory management policy for this property. This will always be
63 | * #mtl_propertyMemoryManagementPolicyAssign if #readonly is \c YES.
64 | */
65 | mtl_propertyMemoryManagementPolicy memoryManagementPolicy;
66 |
67 | /**
68 | * The selector for the getter of this property. This will reflect any
69 | * custom \c getter= attribute provided in the property declaration, or the
70 | * inferred getter name otherwise.
71 | */
72 | SEL getter;
73 |
74 | /**
75 | * The selector for the setter of this property. This will reflect any
76 | * custom \c setter= attribute provided in the property declaration, or the
77 | * inferred setter name otherwise.
78 | *
79 | * @note If #readonly is \c YES, this value will represent what the setter
80 | * \e would be, if the property were writable.
81 | */
82 | SEL setter;
83 |
84 | /**
85 | * The backing instance variable for this property, or \c NULL if \c
86 | * \c @synthesize was not used, and therefore no instance variable exists. This
87 | * would also be the case if the property is implemented dynamically.
88 | */
89 | const char *ivar;
90 |
91 | /**
92 | * If this property is defined as being an instance of a specific class,
93 | * this will be the class object representing it.
94 | *
95 | * This will be \c nil if the property was defined as type \c id, if the
96 | * property is not of an object type, or if the class could not be found at
97 | * runtime.
98 | */
99 | Class objectClass;
100 |
101 | /**
102 | * The type encoding for the value of this property. This is the type as it
103 | * would be returned by the \c \@encode() directive.
104 | */
105 | char type[];
106 | } mtl_propertyAttributes;
107 |
108 | /**
109 | * Returns a pointer to a structure containing information about \a property.
110 | * You must \c free() the returned pointer. Returns \c NULL if there is an error
111 | * obtaining information from \a property.
112 | */
113 | mtl_propertyAttributes *mtl_copyPropertyAttributes (objc_property_t property);
114 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/Mantle/extobjc/EXTScope.h:
--------------------------------------------------------------------------------
1 | //
2 | // EXTScope.h
3 | // extobjc
4 | //
5 | // Created by Justin Spahr-Summers on 2011-05-04.
6 | // Copyright (C) 2012 Justin Spahr-Summers.
7 | // Released under the MIT license.
8 | //
9 |
10 | #import "metamacros.h"
11 |
12 | /**
13 | * \@onExit defines some code to be executed when the current scope exits. The
14 | * code must be enclosed in braces and terminated with a semicolon, and will be
15 | * executed regardless of how the scope is exited, including from exceptions,
16 | * \c goto, \c return, \c break, and \c continue.
17 | *
18 | * Provided code will go into a block to be executed later. Keep this in mind as
19 | * it pertains to memory management, restrictions on assignment, etc. Because
20 | * the code is used within a block, \c return is a legal (though perhaps
21 | * confusing) way to exit the cleanup block early.
22 | *
23 | * Multiple \@onExit statements in the same scope are executed in reverse
24 | * lexical order. This helps when pairing resource acquisition with \@onExit
25 | * statements, as it guarantees teardown in the opposite order of acquisition.
26 | *
27 | * @note This statement cannot be used within scopes defined without braces
28 | * (like a one line \c if). In practice, this is not an issue, since \@onExit is
29 | * a useless construct in such a case anyways.
30 | */
31 | #define onExit \
32 | try {} @finally {} \
33 | __strong mtl_cleanupBlock_t metamacro_concat(mtl_exitBlock_, __LINE__) __attribute__((cleanup(mtl_executeCleanupBlock), unused)) = ^
34 |
35 | /**
36 | * Creates \c __weak shadow variables for each of the variables provided as
37 | * arguments, which can later be made strong again with #strongify.
38 | *
39 | * This is typically used to weakly reference variables in a block, but then
40 | * ensure that the variables stay alive during the actual execution of the block
41 | * (if they were live upon entry).
42 | *
43 | * See #strongify for an example of usage.
44 | */
45 | #define weakify(...) \
46 | try {} @finally {} \
47 | metamacro_foreach_cxt(mtl_weakify_,, __weak, __VA_ARGS__)
48 |
49 | /**
50 | * Like #weakify, but uses \c __unsafe_unretained instead, for targets or
51 | * classes that do not support weak references.
52 | */
53 | #define unsafeify(...) \
54 | try {} @finally {} \
55 | metamacro_foreach_cxt(mtl_weakify_,, __unsafe_unretained, __VA_ARGS__)
56 |
57 | /**
58 | * Strongly references each of the variables provided as arguments, which must
59 | * have previously been passed to #weakify.
60 | *
61 | * The strong references created will shadow the original variable names, such
62 | * that the original names can be used without issue (and a significantly
63 | * reduced risk of retain cycles) in the current scope.
64 | *
65 | * @code
66 |
67 | id foo = [[NSObject alloc] init];
68 | id bar = [[NSObject alloc] init];
69 |
70 | @weakify(foo, bar);
71 |
72 | // this block will not keep 'foo' or 'bar' alive
73 | BOOL (^matchesFooOrBar)(id) = ^ BOOL (id obj){
74 | // but now, upon entry, 'foo' and 'bar' will stay alive until the block has
75 | // finished executing
76 | @strongify(foo, bar);
77 |
78 | return [foo isEqual:obj] || [bar isEqual:obj];
79 | };
80 |
81 | * @endcode
82 | */
83 | #define strongify(...) \
84 | try {} @finally {} \
85 | _Pragma("clang diagnostic push") \
86 | _Pragma("clang diagnostic ignored \"-Wshadow\"") \
87 | metamacro_foreach(mtl_strongify_,, __VA_ARGS__) \
88 | _Pragma("clang diagnostic pop")
89 |
90 | /*** implementation details follow ***/
91 | typedef void (^mtl_cleanupBlock_t)();
92 |
93 | void mtl_executeCleanupBlock (__strong mtl_cleanupBlock_t *block);
94 |
95 | #define mtl_weakify_(INDEX, CONTEXT, VAR) \
96 | CONTEXT __typeof__(VAR) metamacro_concat(VAR, _weak_) = (VAR);
97 |
98 | #define mtl_strongify_(INDEX, VAR) \
99 | __strong __typeof__(VAR) VAR = metamacro_concat(VAR, _weak_);
100 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/Mantle/extobjc/EXTScope.m:
--------------------------------------------------------------------------------
1 | //
2 | // EXTScope.m
3 | // extobjc
4 | //
5 | // Created by Justin Spahr-Summers on 2011-05-04.
6 | // Copyright (C) 2012 Justin Spahr-Summers.
7 | // Released under the MIT license.
8 | //
9 |
10 | #import "EXTScope.h"
11 |
12 | void mtl_executeCleanupBlock (__strong mtl_cleanupBlock_t *block) {
13 | (*block)();
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/WHC_Model/NSObject+WHC_Model.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+WHC_Model.h
3 | // WHC_Model
4 | //
5 | // Created by WHC on 16/7/13.
6 | // Copyright © 2016年 whc. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 | // VERSION:(1.1.0)
27 | #import
28 |
29 | @interface NSObject (WHC_Model)
30 | #pragma mark - json转模型对象 Api -
31 |
32 | /** 说明: 把json数组解析为模型对象数组
33 | *@param array :json数组
34 | *@return 模型对象数组
35 | */
36 | + (NSArray*)whc_ModelWithArray:(NSArray*)array;
37 |
38 | /** 说明: 把json数组解析为模型对象数组
39 | *@param array :json数组
40 | *@return 模型对象数组
41 | */
42 |
43 | + (NSArray*)whc_ModelWithArray:(NSArray*)array classPrefix:(NSString *)prefix;
44 |
45 | /** 说明:把json字典解析为模型对象
46 | *@param dictionary :json字典
47 | *@return 模型对象
48 | */
49 | + (id)whc_ModelWithDictionary:(NSDictionary*)dictionary;
50 |
51 | /** 说明:把json字典解析为模型对象
52 | *@param dictionary :json字典
53 | *@param prefix :自定义模型类前缀名称
54 | *@return 模型对象
55 | */
56 |
57 | + (id)whc_ModelWithDictionary:(NSDictionary*)dictionary classPrefix:(NSString *)prefix;
58 |
59 | /** 说明:把json解析为模型对象
60 | *@param json :json 字符串
61 | *@return 模型对象
62 | */
63 | + (id)whc_ModelWithJson:(NSString *)json;
64 |
65 | /** 说明:把json解析为模型对象
66 | *@param json :json 字符串
67 | *@param keyPath json key的路径
68 | *@return 模型对象
69 | */
70 | + (id)whc_ModelWithJson:(NSString *)json keyPath:(NSString *)keyPath;
71 |
72 | /** 说明:把json解析为模型对象
73 | *@param json :json 字符串
74 | *@param prefix :自定义模型类前缀名称
75 | *@return 模型对象
76 | */
77 |
78 | + (id)whc_ModelWithJson:(NSString *)json classPrefix:(NSString *)prefix;
79 |
80 | /** 说明:把json解析为模型对象
81 | *@param jsonData :jsonData json数据对象
82 | *@return 模型对象
83 | */
84 | + (id)whc_ModelWithJsonData:(NSData *)jsonData;
85 |
86 | /** 说明:把json解析为模型对象
87 | *@param jsonData :jsonData json数据对象
88 | *@param keyPath :json key的路径
89 | *@return 模型对象
90 | */
91 |
92 | + (id)whc_ModelWithJsonData:(NSData *)jsonData keyPath:(NSString *)keyPath;
93 |
94 | /** 说明:把json解析为模型对象
95 | *@param jsonData :jsonData json数据对象
96 | *@param prefix :自定义模型类前缀名称
97 | *@return 模型对象
98 | */
99 | + (id)whc_ModelWithJsonData:(NSData *)jsonData classPrefix:(NSString *)prefix;
100 |
101 | #pragma mark - 模型对象转json Api -
102 |
103 | /** 说明:把模型对象转换为字典
104 | *@return 字典对象
105 | */
106 |
107 | - (NSDictionary *)whc_Dictionary;
108 |
109 | /** 说明:把模型对象转换为json字符串
110 | *@return json字符串
111 | */
112 |
113 | - (NSString *)whc_Json;
114 | @end
115 |
--------------------------------------------------------------------------------
/Benchmark/Vendor/YYModel/YYModel.h:
--------------------------------------------------------------------------------
1 | //
2 | // YYModel.h
3 | // YYModel
4 | //
5 | // Created by ibireme on 15/5/10.
6 | // Copyright (c) 2015 ibireme.
7 | //
8 | // This source code is licensed under the MIT-style license found in the
9 | // LICENSE file in the root directory of this source tree.
10 | //
11 |
12 | #import
13 |
14 | #if __has_include()
15 | FOUNDATION_EXPORT double YYModelVersionNumber;
16 | FOUNDATION_EXPORT const unsigned char YYModelVersionString[];
17 | #import
18 | #import
19 | #else
20 | #import "NSObject+YYModel.h"
21 | #import "YYClassInfo.h"
22 | #endif
23 |
--------------------------------------------------------------------------------
/Benchmark/a.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/netyouli/WHC_Model/1c8008b966b91b0255666146e4c0423ec4d5c00e/Benchmark/a.png
--------------------------------------------------------------------------------
/Benchmark/b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/netyouli/WHC_Model/1c8008b966b91b0255666146e4c0423ec4d5c00e/Benchmark/b.png
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 吴海超
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Result/a.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/netyouli/WHC_Model/1c8008b966b91b0255666146e4c0423ec4d5c00e/Result/a.png
--------------------------------------------------------------------------------
/Result/b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/netyouli/WHC_Model/1c8008b966b91b0255666146e4c0423ec4d5c00e/Result/b.png
--------------------------------------------------------------------------------
/WHC_Model.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |s|
2 |
3 | s.name = "WHC_Model"
4 | s.version = "1.7.1"
5 | s.summary = "iOS平台高效转换引擎json->model,model->json,model->Dictionary,支持模型类继承其他模型类,支持指定路径转换,不区分json的key和模型属性名称大小写,自动处理json中null"
6 |
7 | s.homepage = "https://github.com/netyouli/WHC_Model"
8 |
9 | s.license = "MIT"
10 |
11 | s.author = { "吴海超(WHC)" => "712641411@qq.com" }
12 |
13 | s.source = { :git => "https://github.com/netyouli/WHC_Model.git", :tag => "1.7.1"}
14 |
15 | s.source_files = "WHC_ModelKit/*.{h,m}"
16 |
17 | s.ios.deployment_target = '6.0'
18 | s.osx.deployment_target = '10.9'
19 | s.tvos.deployment_target = '7.0'
20 | # s.public_header_files = "Classes/**/*.h"
21 |
22 |
23 | s.requires_arc = true
24 |
25 |
26 | end
27 |
--------------------------------------------------------------------------------
/WHC_Model.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/WHC_Model.xcodeproj/project.xcworkspace/xcuserdata/WHC.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/netyouli/WHC_Model/1c8008b966b91b0255666146e4c0423ec4d5c00e/WHC_Model.xcodeproj/project.xcworkspace/xcuserdata/WHC.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/WHC_Model.xcodeproj/xcuserdata/.xcassets/build.file:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/netyouli/WHC_Model/1c8008b966b91b0255666146e4c0423ec4d5c00e/WHC_Model.xcodeproj/xcuserdata/.xcassets/build.file
--------------------------------------------------------------------------------
/WHC_Model.xcodeproj/xcuserdata/WHC.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/WHC_Model.xcodeproj/xcuserdata/WHC.xcuserdatad/xcschemes/WHC_Model.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/WHC_Model.xcodeproj/xcuserdata/WHC.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | WHC_Model.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | FECDABA91DC878DE00B510AA
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/WHC_Model/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // WHC_Model
4 | //
5 | // Created by WHC on 16/11/1.
6 | // Copyright © 2016年 WHC. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/WHC_Model/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // WHC_Model
4 | //
5 | // Created by WHC on 16/11/1.
6 | // Copyright © 2016年 WHC. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 |
24 | - (void)applicationWillResignActive:(UIApplication *)application {
25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
27 | }
28 |
29 |
30 | - (void)applicationDidEnterBackground:(UIApplication *)application {
31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
33 | }
34 |
35 |
36 | - (void)applicationWillEnterForeground:(UIApplication *)application {
37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
38 | }
39 |
40 |
41 | - (void)applicationDidBecomeActive:(UIApplication *)application {
42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
43 | }
44 |
45 |
46 | - (void)applicationWillTerminate:(UIApplication *)application {
47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
48 | }
49 |
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/WHC_Model/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/WHC_Model/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/WHC_Model/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/WHC_Model/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UILaunchStoryboardName
24 | LaunchScreen
25 | UIMainStoryboardFile
26 | Main
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/WHC_Model/Model/ModelObject.m:
--------------------------------------------------------------------------------
1 | //
2 | // Model.m
3 | // WHC_Model
4 | //
5 | // Created by WHC on 16/11/1.
6 | // Copyright © 2016年 WHC. All rights reserved.
7 | //
8 |
9 | #import "ModelObject.h"
10 | #import "NSObject+WHC_Model.h"
11 |
12 | @implementation ModelObjectSuper
13 | WHC_CodingImplementation
14 | @end
15 |
16 | @implementation ModelObject
17 | WHC_CodingImplementation
18 | @end
19 |
20 | @implementation Head
21 | WHC_CodingImplementation
22 | @end
23 |
24 | @implementation ChangeRule
25 | WHC_CodingImplementation
26 | @end
27 |
28 | @implementation FeeInfoList
29 | WHC_CodingImplementation
30 | @end
31 |
32 | @implementation EndorseRule
33 | WHC_CodingImplementation
34 | @end
35 |
36 | @implementation RefundRule
37 | WHC_CodingImplementation
38 | @end
39 |
40 | @implementation PolicyRuleList
41 | WHC_CodingImplementation
42 | @end
43 |
44 | @implementation StandardPriceList
45 | WHC_CodingImplementation
46 | @end
47 |
48 | @implementation PriceInfo_Child
49 | WHC_CodingImplementation
50 | @end
51 |
52 | @implementation AirLineShowEntity
53 | WHC_CodingImplementation
54 | @end
55 |
56 | @implementation PriceInfo_Adult
57 | WHC_CodingImplementation
58 | @end
59 |
60 | @implementation LowestPriceCabin
61 | WHC_CodingImplementation
62 | @end
63 |
64 | @implementation CabinInfoList
65 | WHC_CodingImplementation
66 | @end
67 |
68 | @implementation PunctualityRateDetail
69 | WHC_CodingImplementation
70 | @end
71 |
72 | @implementation FlightInfoList
73 | WHC_CodingImplementation
74 | @end
75 |
76 | @implementation FlightListGroupList
77 | WHC_CodingImplementation
78 | @end
79 |
80 | @implementation ResponseBody
81 | WHC_CodingImplementation
82 | @end
83 |
84 |
--------------------------------------------------------------------------------
/WHC_Model/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // WHC_Model
4 | //
5 | // Created by WHC on 16/11/1.
6 | // Copyright © 2016年 WHC. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/WHC_Model/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // WHC_Model
4 | //
5 | // Created by WHC on 16/11/1.
6 | // Copyright © 2016年 WHC. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/WHC_ModelKit/NSObject+WHC_Model.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+WHC_Model.h
3 | // WHC_Model
4 | //
5 | // Created by WHC on 16/7/13.
6 | // Copyright © 2016年 whc. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 | #import
27 |
28 | ///模型对象归档解归档实现
29 | #define WHC_CodingImplementation \
30 | - (id)initWithCoder:(NSCoder *)decoder \
31 | { \
32 | if (self = [super init]) { \
33 | [self whc_Decode:decoder]; \
34 | } \
35 | return self; \
36 | } \
37 | \
38 | - (void)encodeWithCoder:(NSCoder *)encoder \
39 | { \
40 | [self whc_Encode:encoder]; \
41 | }\
42 | - (id)copyWithZone:(NSZone *)zone { return [self whc_Copy]; }
43 |
44 | @protocol WHC_ModelKeyValue
45 | @optional
46 | /// 模型类可自定义属性名称
47 | + (NSDictionary *)whc_ModelReplacePropertyMapper;
48 | /// 模型数组/字典元素对象可自定义类<替换实际属性名,实际类>
49 | + (NSDictionary *)whc_ModelReplaceContainerElementClassMapper;
50 | /// 模型类可自定义属性类型<替换实际属性名,实际类>
51 | + (NSDictionary *)whc_ModelReplacePropertyClassMapper;
52 |
53 | @end
54 |
55 | @interface NSObject (WHC_Model)
56 |
57 | #pragma mark - json转模型对象 Api -
58 |
59 | /** 说明:把json解析为模型对象
60 | *@param json :json数据对象
61 | *@return 模型对象
62 | */
63 | + (id)whc_ModelWithJson:(id)json;
64 |
65 | /** 说明:把json解析为模型对象
66 | *@param json :json数据对象
67 | *@param keyPath :json key的路径
68 | *@return 模型对象
69 | */
70 |
71 | + (id)whc_ModelWithJson:(id)json keyPath:(NSString *)keyPath;
72 |
73 |
74 | #pragma mark - 模型对象转json Api -
75 |
76 | /** 说明:把模型对象转换为字典
77 | *@return 字典对象
78 | */
79 |
80 | - (NSDictionary *)whc_Dictionary;
81 |
82 | /** 说明:把模型对象转换为json字符串
83 | *@return json字符串
84 | */
85 |
86 | - (NSString *)whc_JsonIsFormat:(BOOL)isFormat;
87 |
88 | #pragma mark - 模型对象序列化 Api -
89 |
90 | /// 复制模型对象
91 | - (id)whc_Copy;
92 |
93 | /// 序列化模型对象
94 | - (void)whc_Encode:(NSCoder *)aCoder;
95 |
96 | /// 反序列化模型对象
97 | - (void)whc_Decode:(NSCoder *)aDecoder;
98 | @end
99 |
--------------------------------------------------------------------------------