From 91641ffb01dcf8d303b13216797bb41d1f770124 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Thu, 11 Jun 2015 12:30:52 -0700 Subject: Lightweight generics Added lightweight generics annotations to collection-typed method and protocol signatures to streamline usage of these members in Swift. Lightweight generic type specifiers are wrapped in conditionally-compiled macros for compatibility with Xcode 6.x. Manually preprocess the NS_*_OF() macros in a temporary copy of each header before appledoc sees the headers. Also removed the --ignore flag because we no longer have a private headers folder under include/mbgl/ios/. --- include/mbgl/ios/MGLMapView.h | 12 ++++++------ include/mbgl/ios/MGLTypes.h | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/mbgl/ios/MGLMapView.h b/include/mbgl/ios/MGLMapView.h index 26a5051d41..abe7f851a1 100644 --- a/include/mbgl/ios/MGLMapView.h +++ b/include/mbgl/ios/MGLMapView.h @@ -171,7 +171,7 @@ IB_DESIGNABLE @property (nonatomic, nullable) NSString *mapID __attribute__((unavailable("Use styleID."))); /** URLs of the styles bundled with the library. */ -@property (nonatomic, readonly) NSArray *bundledStyleURLs; +@property (nonatomic, readonly) NS_ARRAY_OF(NSURL *) *bundledStyleURLs; /** URL of the style currently displayed in the receiver. * @@ -181,7 +181,7 @@ IB_DESIGNABLE @property (nonatomic, null_resettable) NSURL *styleURL; /** Currently active style classes, represented as an array of string identifiers. */ -@property (nonatomic) NSArray *styleClasses; +@property (nonatomic) NS_ARRAY_OF(NSString *) *styleClasses; /** Returns a Boolean value indicating whether the style class with the given identifier is currently active. @param styleClass The style class to query for. @@ -203,7 +203,7 @@ IB_DESIGNABLE /** The complete list of annotations associated with the receiver. (read-only) * * The objects in this array must adopt the MGLAnnotation protocol. If no annotations are associated with the map view, the value of this property is `nil`. */ -@property (nonatomic, readonly, nullable) NSArray *annotations; +@property (nonatomic, readonly, nullable) NS_ARRAY_OF(id ) *annotations; /** Adds the specified annotation to the map view. * @param annotation The annotation object to add to the receiver. This object must conform to the MGLAnnotation protocol. The map view retains the specified object. */ @@ -211,7 +211,7 @@ IB_DESIGNABLE /** Adds an array of annotation objects to the map view. * @param annotations An array of annotation objects. Each object in the array must conform to the MGLAnnotation protocol. The map view retains the individual annotation objects. */ -- (void)addAnnotations:(NSArray *)annotations; +- (void)addAnnotations:(NS_ARRAY_OF(id ) *)annotations; /** Removes the specified annotation object from the map view. * @@ -225,12 +225,12 @@ IB_DESIGNABLE * Removing annotation objects disassociates them from the map view entirely, preventing them from being displayed on the map. Thus, you would typically call this method only when you want to hide or delete the specified annotations. * * @param annotations The array of annotations to remove. Objects in the array must conform to the MGLAnnotation protocol. */ -- (void)removeAnnotations:(NSArray *)annotations; +- (void)removeAnnotations:(NS_ARRAY_OF(id ) *)annotations; /** The annotations that are currently selected. * * Assigning a new array to this property selects only the first annotation in the array. */ -@property (nonatomic, copy) NSArray *selectedAnnotations; +@property (nonatomic, copy) NS_ARRAY_OF(id ) *selectedAnnotations; /** Selects the specified annotation and displays a callout view for it. * diff --git a/include/mbgl/ios/MGLTypes.h b/include/mbgl/ios/MGLTypes.h index 3d3892610a..65d5e7846d 100644 --- a/include/mbgl/ios/MGLTypes.h +++ b/include/mbgl/ios/MGLTypes.h @@ -29,3 +29,23 @@ typedef struct { } MGLCoordinateBounds; NS_ASSUME_NONNULL_END + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wvariadic-macros" + #if __has_feature(objc_generics) + /** Inserts a type specifier for a pointer to a lightweight generic with the given collection and object classes. Use a `*` for any non-`id` object classes but no `*` for the collection class. */ + #define NS_ARRAY_OF(ObjectClass...) NSArray + #define NS_MUTABLE_ARRAY_OF(ObjectClass...) NSMutableArray + #define NS_SET_OF(ObjectClass...) NSSet + #define NS_MUTABLE_SET_OF(ObjectClass...) NSMutableSet + #define NS_DICTIONARY_OF(ObjectClass...) NSDictionary + #define NS_MUTABLE_DICTIONARY_OF(ObjectClass...) NSMutableDictionary + #else + #define NS_ARRAY_OF(ObjectClass...) NSArray + #define NS_MUTABLE_ARRAY_OF(ObjectClass...) NSMutableArray + #define NS_SET_OF(ObjectClass...) NSSet + #define NS_MUTABLE_SET_OF(ObjectClass...) NSMutableSet + #define NS_DICTIONARY_OF(ObjectClass...) NSDictionary + #define NS_MUTABLE_DICTIONARY_OF(ObjectClass...) NSMutableDictionary + #endif +#pragma clang diagnostic pop -- cgit v1.2.1