Skip to content

Commit 19b94d7

Browse files
author
grobbins
committed
Update runtime to use block-based IMPs; add macros for Objective-C generics; update project files.
1 parent f670d7b commit 19b94d7

File tree

16 files changed

+592
-888
lines changed

16 files changed

+592
-888
lines changed

Source/GTL.xcodeproj/project.pbxproj

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@
797797
089C1669FE841209C02AAC07 /* Project object */ = {
798798
isa = PBXProject;
799799
attributes = {
800-
LastUpgradeCheck = 0440;
800+
LastUpgradeCheck = 0630;
801801
};
802802
buildConfigurationList = 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "GTL" */;
803803
compatibilityVersion = "Xcode 3.2";
@@ -1032,23 +1032,18 @@
10321032
1DEB913F08733D840010E9CD /* Debug */ = {
10331033
isa = XCBuildConfiguration;
10341034
buildSettings = {
1035-
ARCHS = (
1036-
ppc,
1037-
i386,
1038-
);
1035+
CLANG_STATIC_ANALYZER_MODE = deep;
10391036
COPY_PHASE_STRIP = NO;
10401037
DEAD_CODE_STRIPPING = NO;
10411038
DEPLOYMENT_POSTPROCESSING = NO;
10421039
ENABLE_STRICT_OBJC_MSGSEND = YES;
10431040
GCC_C_LANGUAGE_STANDARD = c99;
1044-
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
10451041
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
1046-
GCC_MODEL_TUNING = G5;
10471042
GCC_OPTIMIZATION_LEVEL = 0;
10481043
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
10491044
GCC_WARN_ABOUT_RETURN_TYPE = YES;
10501045
GCC_WARN_UNUSED_VARIABLE = YES;
1051-
MACOSX_DEPLOYMENT_TARGET = "";
1046+
ONLY_ACTIVE_ARCH = YES;
10521047
OTHER_CFLAGS = "-DDEBUG=1";
10531048
SDKROOT = macosx;
10541049
WARNING_CFLAGS = (
@@ -1075,23 +1070,17 @@
10751070
1DEB914008733D840010E9CD /* Release */ = {
10761071
isa = XCBuildConfiguration;
10771072
buildSettings = {
1078-
ARCHS = (
1079-
ppc,
1080-
i386,
1081-
);
1073+
CLANG_STATIC_ANALYZER_MODE = deep;
10821074
COPY_PHASE_STRIP = YES;
10831075
DEAD_CODE_STRIPPING = YES;
10841076
DEPLOYMENT_POSTPROCESSING = YES;
10851077
ENABLE_STRICT_OBJC_MSGSEND = YES;
10861078
GCC_C_LANGUAGE_STANDARD = c99;
1087-
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
10881079
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
1089-
GCC_MODEL_TUNING = G5;
10901080
GCC_OPTIMIZATION_LEVEL = s;
10911081
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
10921082
GCC_WARN_ABOUT_RETURN_TYPE = YES;
10931083
GCC_WARN_UNUSED_VARIABLE = YES;
1094-
MACOSX_DEPLOYMENT_TARGET = "";
10951084
SDKROOT = macosx;
10961085
WARNING_CFLAGS = (
10971086
"-Wall",
@@ -1117,13 +1106,11 @@
11171106
4F14A9E00B1276B70072EBB8 /* Debug */ = {
11181107
isa = XCBuildConfiguration;
11191108
buildSettings = {
1120-
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
11211109
COMBINE_HIDPI_IMAGES = YES;
11221110
FRAMEWORK_SEARCH_PATHS = (
11231111
"$(value)",
11241112
"$(DEVELOPER_FRAMEWORKS_DIR_QUOTED)",
11251113
);
1126-
GCC_C_LANGUAGE_STANDARD = gnu99;
11271114
GCC_DYNAMIC_NO_PIC = NO;
11281115
GCC_PRECOMPILE_PREFIX_HEADER = YES;
11291116
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h";
@@ -1146,13 +1133,11 @@
11461133
4F14A9E10B1276B70072EBB8 /* Release */ = {
11471134
isa = XCBuildConfiguration;
11481135
buildSettings = {
1149-
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
11501136
COMBINE_HIDPI_IMAGES = YES;
11511137
FRAMEWORK_SEARCH_PATHS = (
11521138
"$(value)",
11531139
"$(DEVELOPER_FRAMEWORKS_DIR_QUOTED)",
11541140
);
1155-
GCC_C_LANGUAGE_STANDARD = gnu99;
11561141
GCC_DYNAMIC_NO_PIC = NO;
11571142
GCC_PRECOMPILE_PREFIX_HEADER = YES;
11581143
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h";
@@ -1175,8 +1160,6 @@
11751160
4F1AD9090B71606100DC0485 /* Debug */ = {
11761161
isa = XCBuildConfiguration;
11771162
buildSettings = {
1178-
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
1179-
GCC_ENABLE_OBJC_GC = unsupported;
11801163
INFOPLIST_FILE = "Resources/DevTestTool-Info.plist";
11811164
MACOSX_DEPLOYMENT_TARGET = 10.7;
11821165
PRODUCT_NAME = DevelopmentTestTool;
@@ -1186,8 +1169,6 @@
11861169
4F1AD90A0B71606100DC0485 /* Release */ = {
11871170
isa = XCBuildConfiguration;
11881171
buildSettings = {
1189-
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
1190-
GCC_ENABLE_OBJC_GC = unsupported;
11911172
INFOPLIST_FILE = "Resources/DevTestTool-Info.plist";
11921173
MACOSX_DEPLOYMENT_TARGET = 10.7;
11931174
PRODUCT_NAME = DevelopmentTestTool;
@@ -1223,7 +1204,6 @@
12231204
4F38F7120B66EF2C00B24B81 /* Debug */ = {
12241205
isa = XCBuildConfiguration;
12251206
buildSettings = {
1226-
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
12271207
COMBINE_HIDPI_IMAGES = YES;
12281208
DYLIB_COMPATIBILITY_VERSION = 1;
12291209
DYLIB_CURRENT_VERSION = 1;
@@ -1247,7 +1227,6 @@
12471227
4F38F7130B66EF2C00B24B81 /* Release */ = {
12481228
isa = XCBuildConfiguration;
12491229
buildSettings = {
1250-
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
12511230
COMBINE_HIDPI_IMAGES = YES;
12521231
DYLIB_COMPATIBILITY_VERSION = 1;
12531232
DYLIB_CURRENT_VERSION = 1;

Source/GTLDefines.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,25 @@
138138
#define GTL_NONNULL(x)
139139
#endif
140140
#endif
141+
142+
#ifndef GTL_DECLARE_GENERICS
143+
#if __has_feature(objc_generics) \
144+
&& ((!TARGET_OS_IPHONE && defined(MAC_OS_X_VERSION_10_11) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_11) \
145+
|| (TARGET_OS_IPHONE && defined(__IPHONE_9_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_9_0))
146+
#define GTL_DECLARE_GENERICS 1
147+
#else
148+
#define GTL_DECLARE_GENERICS 0
149+
#endif
150+
#endif
151+
152+
#ifndef GTL_NSArrayOf
153+
#if GTL_DECLARE_GENERICS
154+
#define GTL_NSArrayOf(value) NSArray<value>
155+
#define GTL_NSDictionaryOf(key, value) NSDictionary<key, value>
156+
#define GTL_NSMutableDictionaryOf(key, value) NSMutableDictionary<key, value>
157+
#else
158+
#define GTL_NSArrayOf(value) NSArray
159+
#define GTL_NSDictionaryOf(key, value) NSDictionary
160+
#define GTL_NSMutableDictionaryOf(key, value) NSMutableDictionary
161+
#endif // GTL_DECLARE_GENERICS
162+
#endif // GTL_NSArrayOf

Source/Objects/GTLBatchQuery.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
}
3434

3535
// Queries included in this batch. Each query should have a unique requestID.
36-
@property (retain) NSArray *queries;
36+
@property (retain) GTL_NSArrayOf(GTLQuery *) *queries;
3737

3838
// Clients may set this to YES to disallow authorization. Defaults to NO.
3939
@property (assign) BOOL shouldSkipAuthorization;
@@ -42,11 +42,11 @@
4242
//
4343
// These headers override the same keys from the service object's
4444
// additionalHTTPHeaders.
45-
@property (copy) NSDictionary *additionalHTTPHeaders;
45+
@property (copy) GTL_NSDictionaryOf(NSString *, NSString *) *additionalHTTPHeaders;
4646

4747
// Any URL query parameters to add to the query (useful for debugging with some
4848
// services).
49-
@property (copy) NSDictionary *urlQueryParameters;
49+
@property (copy) GTL_NSDictionaryOf(NSString *, NSString *) *urlQueryParameters;
5050

5151
// Apps may provide a test block on the query or service to avoid network activity
5252
// during testing.
@@ -55,7 +55,7 @@
5555
@property (copy) GTLQueryTestBlock testBlock;
5656

5757
+ (instancetype)batchQuery;
58-
+ (instancetype)batchQueryWithQueries:(NSArray *)array;
58+
+ (instancetype)batchQueryWithQueries:(GTL_NSArrayOf(GTLQuery *) *)array;
5959

6060
- (void)addQuery:(GTLQuery *)query GTL_NONNULL((1));
6161

Source/Objects/GTLDateTime.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,12 +510,12 @@ - (void)setFromRFC3339String:(NSString *)str {
510510
NSInteger totalOffset = kGTLUndefinedDateComponent;
511511
self.universalTime = NO;
512512

513-
if (sign != nil && [sign caseInsensitiveCompare:@"Z"] == NSOrderedSame) {
513+
if (sign == nil || [sign caseInsensitiveCompare:@"Z"] == NSOrderedSame) {
514514

515515
self.universalTime = YES;
516516
totalOffset = 0;
517517

518-
} else if (sign != nil) {
518+
} else {
519519

520520
totalOffset = (60 * offsetMinute) + (60 * 60 * offsetHour);
521521

Source/Objects/GTLErrorObject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
@interface GTLErrorObject : GTLObject
2525
@property (retain) NSNumber *code;
2626
@property (retain) NSString *message;
27-
@property (retain) NSArray *data; // of GTLErrorObjectData
27+
@property (retain) GTL_NSArrayOf(GTLErrorObjectData *) *data;
2828

2929
// Convenience accessor for creating an NSError from a GTLErrorObject.
3030
@property (readonly) NSError *foundationError;

Source/Objects/GTLObject.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@
2626
#import "GTLUtilities.h"
2727
#import "GTLDateTime.h"
2828

29+
@class GTLObject;
30+
2931
@protocol GTLCollectionProtocol
3032
@optional
31-
@property (retain) NSArray *items;
33+
@property (retain) GTL_NSArrayOf(GTLObject *) *items;
3234
@end
3335

3436
@protocol GTLBatchItemCreationProtocol
@@ -52,9 +54,9 @@
5254
NSMutableDictionary *userProperties_;
5355
}
5456

55-
@property (nonatomic, retain) NSMutableDictionary *JSON;
56-
@property (nonatomic, retain) NSDictionary *surrogates;
57-
@property (nonatomic, retain) NSMutableDictionary *userProperties;
57+
@property (nonatomic, retain) GTL_NSMutableDictionaryOf(id, id) *JSON;
58+
@property (nonatomic, retain) GTL_NSDictionaryOf(Class, Class) *surrogates;
59+
@property (nonatomic, retain) GTL_NSMutableDictionaryOf(NSString *, id) *userProperties;
5860

5961
///////////////////////////////////////////////////////////////////////////////
6062
//
@@ -76,13 +78,13 @@
7678

7779
// Returns the list of keys in this object's JSON that aren't listed as
7880
// properties on the object.
79-
- (NSArray *)additionalJSONKeys;
81+
- (GTL_NSArrayOf(NSString *) *)additionalJSONKeys;
8082

8183
// Any keys in the JSON that aren't listed as @properties on the object
8284
// are counted as "additional properties". These allow you to get/set them.
8385
- (id)additionalPropertyForName:(NSString *)name;
8486
- (void)setAdditionalProperty:(id)obj forName:(NSString *)name GTL_NONNULL((2));
85-
- (NSDictionary *)additionalProperties;
87+
- (GTL_NSDictionaryOf(NSString *, id) *)additionalProperties;
8688

8789
// User properties are supported for client convenience, but are not copied by
8890
// copyWithZone. User Properties keys beginning with _ are reserved by the library.
@@ -184,7 +186,7 @@
184186
@end
185187

186188
@interface GTLCollectionObject (DynamicMethods)
187-
- (NSArray *)items;
189+
- (GTL_NSArrayOf(GTLObject *) *)items;
188190
@end
189191

190192
// Base object use for when an service method directly returns an array instead

Source/Objects/GTLObject.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ - (NSString *)description {
467467
if ([rawValue isKindOfClass:[NSDictionary class]]) {
468468
// for dictionaries, show the list of keys:
469469
// {key1,key2,key3}
470-
NSString *subkeyList = [[rawValue allKeys] componentsJoinedByString:@","];
470+
NSString *subkeyList = [[(NSDictionary *)rawValue allKeys] componentsJoinedByString:@","];
471471
value = [NSString stringWithFormat:@"{%@}", subkeyList];
472472
} else if ([rawValue isKindOfClass:[NSArray class]]) {
473473
// for arrays, show the number of items in the array:

Source/Objects/GTLQuery.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
- (BOOL)isBatchQuery;
2828
- (BOOL)shouldSkipAuthorization;
2929
- (void)executionDidStop;
30-
- (NSDictionary *)additionalHTTPHeaders;
31-
- (NSDictionary *)urlQueryParameters;
30+
- (GTL_NSDictionaryOf(NSString *, NSString *) *)additionalHTTPHeaders;
31+
- (GTL_NSDictionaryOf(NSString *, NSString *) *)urlQueryParameters;
3232
- (GTLUploadParameters *)uploadParameters;
3333
@end
3434

@@ -92,14 +92,14 @@ typedef void (^GTLQueryTestBlock)(GTLServiceTicket *testTicket, GTLQueryTestResp
9292

9393
// Any URL query parameters to add to the query (useful for debugging with some
9494
// services).
95-
@property (copy) NSDictionary *urlQueryParameters;
95+
@property (copy) GTL_NSDictionaryOf(NSString *, NSString *) *urlQueryParameters;
9696

9797
// Any additional HTTP headers for this query. Not valid when this query
9898
// is added to a batch.
9999
//
100100
// These headers override the same keys from the service object's
101101
// additionalHTTPHeaders.
102-
@property (copy) NSDictionary *additionalHTTPHeaders;
102+
@property (copy) GTL_NSDictionaryOf(NSString *, NSString *) *additionalHTTPHeaders;
103103

104104
// The GTLObject subclass expected for results (used if the result doesn't
105105
// include a kind attribute).

0 commit comments

Comments
 (0)