Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit 93f79bb

Browse files
committed
[ios, macos] Marked C array parameters as const
Fixes #7214.
1 parent 83e134e commit 93f79bb

15 files changed

+28
-26
lines changed

platform/darwin/src/MGLMultiPoint.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ NS_ASSUME_NONNULL_BEGIN
5656
@param coords The array of coordinates defining the shape. The data in this
5757
array is copied to the object.
5858
*/
59-
- (void)replaceCoordinatesInRange:(NSRange)range withCoordinates:(CLLocationCoordinate2D *)coords;
59+
- (void)replaceCoordinatesInRange:(NSRange)range withCoordinates:(const CLLocationCoordinate2D *)coords;
6060

6161
/**
6262
Appends one or more coordinates for the shape, which will instantaneously
@@ -66,7 +66,7 @@ NS_ASSUME_NONNULL_BEGIN
6666
array is copied to the new object.
6767
@param count The number of items in the `coords` array.
6868
*/
69-
- (void)appendCoordinates:(CLLocationCoordinate2D *)coords count:(NSUInteger)count;
69+
- (void)appendCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count;
7070

7171
@end
7272

platform/darwin/src/MGLMultiPoint.mm

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ @implementation MGLMultiPoint
1818
std::vector<CLLocationCoordinate2D> _coordinates;
1919
}
2020

21-
- (instancetype)initWithCoordinates:(CLLocationCoordinate2D *)coords count:(NSUInteger)count
21+
- (instancetype)initWithCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count
2222
{
2323
self = [super init];
2424

@@ -65,15 +65,15 @@ - (void)getCoordinates:(CLLocationCoordinate2D *)coords range:(NSRange)range
6565
std::copy(_coordinates.begin() + range.location, _coordinates.begin() + NSMaxRange(range), coords);
6666
}
6767

68-
- (void)appendCoordinates:(CLLocationCoordinate2D *)coords count:(NSUInteger)count
68+
- (void)appendCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count
6969
{
7070
[self willChangeValueForKey:@"coordinates"];
7171
_coordinates.insert(_coordinates.end(), count, *coords);
7272
[self computeBounds];
7373
[self didChangeValueForKey:@"coordinates"];
7474
}
7575

76-
- (void)replaceCoordinatesInRange:(NSRange)range withCoordinates:(CLLocationCoordinate2D *)coords
76+
- (void)replaceCoordinatesInRange:(NSRange)range withCoordinates:(const CLLocationCoordinate2D *)coords
7777
{
7878
if (range.length == 0)
7979
{

platform/darwin/src/MGLMultiPoint_Private.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
1818

1919
@interface MGLMultiPoint (Private)
2020

21-
- (instancetype)initWithCoordinates:(CLLocationCoordinate2D *)coords count:(NSUInteger)count;
21+
- (instancetype)initWithCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count;
2222
- (BOOL)intersectsOverlayBounds:(MGLCoordinateBounds)overlayBounds;
2323

2424
/** Constructs a shape annotation object, asking the delegate for style values. */

platform/darwin/src/MGLPointCollection.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
@param count The number of items in the `coords` array.
2727
@return A new point collection object.
2828
*/
29-
+ (instancetype)pointCollectionWithCoordinates:(CLLocationCoordinate2D *)coords count:(NSUInteger)count;
29+
+ (instancetype)pointCollectionWithCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count;
3030

3131
/** The array of coordinates associated with the shape. */
3232
@property (nonatomic, readonly) CLLocationCoordinate2D *coordinates NS_RETURNS_INNER_POINTER;

platform/darwin/src/MGLPointCollection.mm

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ @implementation MGLPointCollection
1212
std::vector<CLLocationCoordinate2D> _coordinates;
1313
}
1414

15-
+ (instancetype)pointCollectionWithCoordinates:(CLLocationCoordinate2D *)coords count:(NSUInteger)count
15+
+ (instancetype)pointCollectionWithCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count
1616
{
1717
return [[self alloc] initWithCoordinates:coords count:count];
1818
}
1919

20-
- (instancetype)initWithCoordinates:(CLLocationCoordinate2D *)coords count:(NSUInteger)count
20+
- (instancetype)initWithCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count
2121
{
2222
self = [super init];
2323
if (self)

platform/darwin/src/MGLPointCollection_Private.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ NS_ASSUME_NONNULL_BEGIN
44

55
@interface MGLPointCollection (Private)
66

7-
- (instancetype)initWithCoordinates:(CLLocationCoordinate2D *)coords count:(NSUInteger)count;
7+
- (instancetype)initWithCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count;
88

99
@end
1010

platform/darwin/src/MGLPolygon.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ NS_ASSUME_NONNULL_BEGIN
3636
@param count The number of items in the `coords` array.
3737
@return A new polygon object.
3838
*/
39-
+ (instancetype)polygonWithCoordinates:(CLLocationCoordinate2D *)coords count:(NSUInteger)count;
39+
+ (instancetype)polygonWithCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count;
4040

4141
/**
4242
Creates and returns an `MGLPolygon` object from the specified set of
@@ -50,7 +50,7 @@ NS_ASSUME_NONNULL_BEGIN
5050
is considered to have no interior polygons.
5151
@return A new polygon object.
5252
*/
53-
+ (instancetype)polygonWithCoordinates:(CLLocationCoordinate2D *)coords count:(NSUInteger)count interiorPolygons:(nullable NS_ARRAY_OF(MGLPolygon *) *)interiorPolygons;
53+
+ (instancetype)polygonWithCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count interiorPolygons:(nullable NS_ARRAY_OF(MGLPolygon *) *)interiorPolygons;
5454

5555
@end
5656

platform/darwin/src/MGLPolygon.mm

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ @implementation MGLPolygon
99

1010
@dynamic overlayBounds;
1111

12-
+ (instancetype)polygonWithCoordinates:(CLLocationCoordinate2D *)coords count:(NSUInteger)count {
12+
+ (instancetype)polygonWithCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count {
1313
return [self polygonWithCoordinates:coords count:count interiorPolygons:nil];
1414
}
1515

16-
+ (instancetype)polygonWithCoordinates:(CLLocationCoordinate2D *)coords count:(NSUInteger)count interiorPolygons:(NSArray<MGLPolygon *> *)interiorPolygons {
16+
+ (instancetype)polygonWithCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count interiorPolygons:(NSArray<MGLPolygon *> *)interiorPolygons {
1717
return [[self alloc] initWithCoordinates:coords count:count interiorPolygons:interiorPolygons];
1818
}
1919

20-
- (instancetype)initWithCoordinates:(CLLocationCoordinate2D *)coords count:(NSUInteger)count interiorPolygons:(NSArray<MGLPolygon *> *)interiorPolygons {
20+
- (instancetype)initWithCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count interiorPolygons:(NSArray<MGLPolygon *> *)interiorPolygons {
2121
if (self = [super initWithCoordinates:coords count:count]) {
2222
if (interiorPolygons.count) {
2323
_interiorPolygons = interiorPolygons;

platform/darwin/src/MGLPolyline.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN
2525
@param count The number of items in the `coords` array.
2626
@return A new polyline object.
2727
*/
28-
+ (instancetype)polylineWithCoordinates:(CLLocationCoordinate2D *)coords count:(NSUInteger)count;
28+
+ (instancetype)polylineWithCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count;
2929

3030
@end
3131

platform/darwin/src/MGLPolyline.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ @implementation MGLPolyline
99

1010
@dynamic overlayBounds;
1111

12-
+ (instancetype)polylineWithCoordinates:(CLLocationCoordinate2D *)coords
12+
+ (instancetype)polylineWithCoordinates:(const CLLocationCoordinate2D *)coords
1313
count:(NSUInteger)count
1414
{
1515
return [[self alloc] initWithCoordinates:coords count:count];

platform/ios/CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,15 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
4949
### Annotations
5050

5151
* Added new methods to MGLMultiPoint for changing or appending vertices along polyline annotations and the exteriors of polygon annotations. ([#6565](https://github.com/mapbox/mapbox-gl-native/pull/6565))
52-
* Added new APIs to MGLMapView to query for visible annotations. Combined with `-[MGLMapView viewForAnnotation:]`, these APIs can be used to access all visible annotation views. ([6061](https://github.com/mapbox/mapbox-gl-native/pull/6061))
52+
* Added new APIs to MGLMapView to query for visible annotations. Combined with `-[MGLMapView viewForAnnotation:]`, these APIs can be used to access all visible annotation views. ([6061](https://github.com/mapbox/mapbox-gl-native/pull/6061))
5353
* Fixed an issue causing offscreen annotation views to be updated even when they were in the reuse queue. ([#5987](https://github.com/mapbox/mapbox-gl-native/pull/5987))
5454
* Fixed an issue preventing MGLAnnotationView from animating when its coordinate changes. ([#6215](https://github.com/mapbox/mapbox-gl-native/pull/6215))
5555
* Fixed an issue causing the wrong annotation view to be selected when tapping an annotation view with a center offset applied. ([#5931](https://github.com/mapbox/mapbox-gl-native/pull/5931))
5656
* Fixed an issue that assigned annotation views to polyline and polygon annotations. ([#5770](https://github.com/mapbox/mapbox-gl-native/pull/5770))
5757
* Per documentation, the first and last coordinates in an MGLPolygon must be identical in order for the polygon to draw correctly. The same is true for an MGLPolygon’s interior polygon. ([#5514](https://github.com/mapbox/mapbox-gl-native/pull/5514))
5858
* To make an MGLPolyline or MGLPolygon span the antimeridian, specify coordinates with longitudes greater than 180° or less than −180°. ([#6088](https://github.com/mapbox/mapbox-gl-native/pull/6088))
5959
* Deprecated `-[MGLMapViewDelegate mapView:alphaForShapeAnnotation:]` in favor of specifying an alpha component via `-[MGLMapViewDelegate mapView:strokeColorForShapeAnnotation:]` or `-[MGLMapViewDelegate mapView:fillColorForPolygonAnnotation:]`. ([#6706](https://github.com/mapbox/mapbox-gl-native/pull/6706))
60+
* Various method arguments that are represented as C arrays of `CLLocationCoordinate2D` instances have been marked `const` to streamline bridging to Swift. ([#7215](https://github.com/mapbox/mapbox-gl-native/pull/7215))
6061
* Fixed an issue that caused an annotation view to disappear if it isn’t created using the annotation view reuse queue. ([#6485](https://github.com/mapbox/mapbox-gl-native/pull/6485))
6162
* Fixed an issue that could reset user-added transformations on annotation views. ([#6166](https://github.com/mapbox/mapbox-gl-native/pull/6166))
6263
* Improved the performance of relocating a non-view-backed point annotation by changing its `coordinate` property. ([#5385](https://github.com/mapbox/mapbox-gl-native/pull/5385))

platform/ios/src/MGLMapView.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ IB_DESIGNABLE
601601
@param animated Specify `YES` to animate the change by smoothly scrolling and
602602
zooming or `NO` to immediately display the given bounds.
603603
*/
604-
- (void)setVisibleCoordinates:(CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets animated:(BOOL)animated;
604+
- (void)setVisibleCoordinates:(const CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets animated:(BOOL)animated;
605605

606606
/**
607607
Changes the receiver’s viewport to fit all of the given coordinates and
@@ -618,7 +618,7 @@ IB_DESIGNABLE
618618
@param function The timing function to animate the change.
619619
@param completion The block executed after the animation finishes.
620620
*/
621-
- (void)setVisibleCoordinates:(CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets direction:(CLLocationDirection)direction duration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function completionHandler:(nullable void (^)(void))completion;
621+
- (void)setVisibleCoordinates:(const CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets direction:(CLLocationDirection)direction duration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function completionHandler:(nullable void (^)(void))completion;
622622

623623
/**
624624
Sets the visible region so that the map displays the specified annotations.

platform/ios/src/MGLMapView.mm

+5-5
Original file line numberDiff line numberDiff line change
@@ -2352,27 +2352,27 @@ - (void)setVisibleCoordinateBounds:(MGLCoordinateBounds)bounds edgePadding:(UIEd
23522352
animated:animated];
23532353
}
23542354

2355-
- (void)setVisibleCoordinates:(CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets animated:(BOOL)animated
2355+
- (void)setVisibleCoordinates:(const CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets animated:(BOOL)animated
23562356
{
23572357
[self setVisibleCoordinates:coordinates count:count edgePadding:insets direction:self.direction animated:animated];
23582358
}
23592359

2360-
- (void)setVisibleCoordinates:(CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets direction:(CLLocationDirection)direction animated:(BOOL)animated
2360+
- (void)setVisibleCoordinates:(const CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets direction:(CLLocationDirection)direction animated:(BOOL)animated
23612361
{
23622362
[self setVisibleCoordinates:coordinates count:count edgePadding:insets direction:direction duration:animated ? MGLAnimationDuration : 0 animationTimingFunction:nil];
23632363
}
23642364

2365-
- (void)setVisibleCoordinates:(CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets direction:(CLLocationDirection)direction duration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function {
2365+
- (void)setVisibleCoordinates:(const CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets direction:(CLLocationDirection)direction duration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function {
23662366
[self setVisibleCoordinates:coordinates count:count edgePadding:insets direction:direction duration:duration animationTimingFunction:function completionHandler:NULL];
23672367
}
23682368

2369-
- (void)setVisibleCoordinates:(CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets direction:(CLLocationDirection)direction duration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function completionHandler:(nullable void (^)(void))completion
2369+
- (void)setVisibleCoordinates:(const CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets direction:(CLLocationDirection)direction duration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function completionHandler:(nullable void (^)(void))completion
23702370
{
23712371
self.userTrackingMode = MGLUserTrackingModeNone;
23722372
[self _setVisibleCoordinates:coordinates count:count edgePadding:insets direction:direction duration:duration animationTimingFunction:function completionHandler:completion];
23732373
}
23742374

2375-
- (void)_setVisibleCoordinates:(CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets direction:(CLLocationDirection)direction duration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function completionHandler:(nullable void (^)(void))completion
2375+
- (void)_setVisibleCoordinates:(const CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets direction:(CLLocationDirection)direction duration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function completionHandler:(nullable void (^)(void))completion
23762376
{
23772377
_mbglMap->cancelTransitions();
23782378

platform/macos/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
* Added new methods to MGLMultiPoint for changing or appending vertices along polyline annotations and the exteriors of polygon annotations. ([#6565](https://github.com/mapbox/mapbox-gl-native/pull/6565))
3636
* Added new APIs to MGLMapView to query for visible annotations. ([6061](https://github.com/mapbox/mapbox-gl-native/pull/6061))
3737
* Deprecated `-[MGLMapViewDelegate mapView:alphaForShapeAnnotation:]` in favor of specifying an alpha component via `-[MGLMapViewDelegate mapView:strokeColorForShapeAnnotation:]` or `-[MGLMapViewDelegate mapView:fillColorForPolygonAnnotation:]`. ([#6706](https://github.com/mapbox/mapbox-gl-native/pull/6706))
38+
* Various method arguments that are represented as C arrays of `CLLocationCoordinate2D` instances have been marked `const` to streamline bridging to Swift. ([#7215](https://github.com/mapbox/mapbox-gl-native/pull/7215))
3839
* To make an MGLPolyline or MGLPolygon span the antimeridian, specify coordinates with longitudes greater than 180° or less than −180°. ([#6088](https://github.com/mapbox/mapbox-gl-native/pull/6088))
3940
* Fixed an issue where placing a point annotation on Null Island also placed a duplicate annotation on its antipode. ([#3563](https://github.com/mapbox/mapbox-gl-native/pull/3563))
4041
* Improved the precision of annotations at zoom levels greater than 18. ([#5517](https://github.com/mapbox/mapbox-gl-native/pull/5517))

platform/macos/macos.xcodeproj/project.pbxproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,8 @@
723723
DAE6C36C1CC31E2A00DB3429 /* MGLGeometry_Private.h */,
724724
DAE6C34C1CC31E0400DB3429 /* MGLGeometry.h */,
725725
DAE6C36D1CC31E2A00DB3429 /* MGLGeometry.mm */,
726-
DAE6C36F1CC31E2A00DB3429 /* MGLMultiPoint_Private.h */,
727726
DAE6C34E1CC31E0400DB3429 /* MGLMultiPoint.h */,
727+
DAE6C36F1CC31E2A00DB3429 /* MGLMultiPoint_Private.h */,
728728
DAE6C3701CC31E2A00DB3429 /* MGLMultiPoint.mm */,
729729
DAE6C3521CC31E0400DB3429 /* MGLOverlay.h */,
730730
DAE6C3531CC31E0400DB3429 /* MGLPointAnnotation.h */,

0 commit comments

Comments
 (0)