Annotate the GPBArray enumerate* apis with NS_NOESCAPE.
This should help the Swift compiler if these apis are used because it
changes the codegen to not need copies/retains.
diff --git a/objectivec/GPBArray.h b/objectivec/GPBArray.h
index 638b288..3d22cb8 100644
--- a/objectivec/GPBArray.h
+++ b/objectivec/GPBArray.h
@@ -134,7 +134,7 @@
* **idx**: The index of the current value.
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
-- (void)enumerateValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block;
+- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block;
/**
* Enumerates the values on this array with the given block.
@@ -146,7 +146,7 @@
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
- usingBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block;
+ usingBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block;
/**
* Adds a value to this array.
@@ -306,7 +306,7 @@
* **idx**: The index of the current value.
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
-- (void)enumerateValuesWithBlock:(void (^)(uint32_t value, NSUInteger idx, BOOL *stop))block;
+- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(uint32_t value, NSUInteger idx, BOOL *stop))block;
/**
* Enumerates the values on this array with the given block.
@@ -318,7 +318,7 @@
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
- usingBlock:(void (^)(uint32_t value, NSUInteger idx, BOOL *stop))block;
+ usingBlock:(void (NS_NOESCAPE ^)(uint32_t value, NSUInteger idx, BOOL *stop))block;
/**
* Adds a value to this array.
@@ -478,7 +478,7 @@
* **idx**: The index of the current value.
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
-- (void)enumerateValuesWithBlock:(void (^)(int64_t value, NSUInteger idx, BOOL *stop))block;
+- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int64_t value, NSUInteger idx, BOOL *stop))block;
/**
* Enumerates the values on this array with the given block.
@@ -490,7 +490,7 @@
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
- usingBlock:(void (^)(int64_t value, NSUInteger idx, BOOL *stop))block;
+ usingBlock:(void (NS_NOESCAPE ^)(int64_t value, NSUInteger idx, BOOL *stop))block;
/**
* Adds a value to this array.
@@ -650,7 +650,7 @@
* **idx**: The index of the current value.
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
-- (void)enumerateValuesWithBlock:(void (^)(uint64_t value, NSUInteger idx, BOOL *stop))block;
+- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(uint64_t value, NSUInteger idx, BOOL *stop))block;
/**
* Enumerates the values on this array with the given block.
@@ -662,7 +662,7 @@
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
- usingBlock:(void (^)(uint64_t value, NSUInteger idx, BOOL *stop))block;
+ usingBlock:(void (NS_NOESCAPE ^)(uint64_t value, NSUInteger idx, BOOL *stop))block;
/**
* Adds a value to this array.
@@ -822,7 +822,7 @@
* **idx**: The index of the current value.
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
-- (void)enumerateValuesWithBlock:(void (^)(float value, NSUInteger idx, BOOL *stop))block;
+- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(float value, NSUInteger idx, BOOL *stop))block;
/**
* Enumerates the values on this array with the given block.
@@ -834,7 +834,7 @@
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
- usingBlock:(void (^)(float value, NSUInteger idx, BOOL *stop))block;
+ usingBlock:(void (NS_NOESCAPE ^)(float value, NSUInteger idx, BOOL *stop))block;
/**
* Adds a value to this array.
@@ -994,7 +994,7 @@
* **idx**: The index of the current value.
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
-- (void)enumerateValuesWithBlock:(void (^)(double value, NSUInteger idx, BOOL *stop))block;
+- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(double value, NSUInteger idx, BOOL *stop))block;
/**
* Enumerates the values on this array with the given block.
@@ -1006,7 +1006,7 @@
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
- usingBlock:(void (^)(double value, NSUInteger idx, BOOL *stop))block;
+ usingBlock:(void (NS_NOESCAPE ^)(double value, NSUInteger idx, BOOL *stop))block;
/**
* Adds a value to this array.
@@ -1166,7 +1166,7 @@
* **idx**: The index of the current value.
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
-- (void)enumerateValuesWithBlock:(void (^)(BOOL value, NSUInteger idx, BOOL *stop))block;
+- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(BOOL value, NSUInteger idx, BOOL *stop))block;
/**
* Enumerates the values on this array with the given block.
@@ -1178,7 +1178,7 @@
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
- usingBlock:(void (^)(BOOL value, NSUInteger idx, BOOL *stop))block;
+ usingBlock:(void (NS_NOESCAPE ^)(BOOL value, NSUInteger idx, BOOL *stop))block;
/**
* Adds a value to this array.
@@ -1369,7 +1369,7 @@
* **idx**: The index of the current value.
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
-- (void)enumerateValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block;
+- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block;
/**
* Enumerates the values on this array with the given block.
@@ -1381,7 +1381,7 @@
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
- usingBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block;
+ usingBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block;
// These methods bypass the validationFunc to provide access to values that were not
// known at the time the binary was compiled.
@@ -1403,7 +1403,7 @@
* **idx**: The index of the current value.
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
-- (void)enumerateRawValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block;
+- (void)enumerateRawValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block;
/**
* Enumerates the values on this array with the given block.
@@ -1415,7 +1415,7 @@
* **stop**: A pointer to a boolean that when set stops the enumeration.
**/
- (void)enumerateRawValuesWithOptions:(NSEnumerationOptions)opts
- usingBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block;
+ usingBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block;
// If value is not a valid enumerator as defined by validationFunc, these
// methods will assert in debug, and will log in release and assign the value
@@ -1779,7 +1779,7 @@
//% * **idx**: The index of the current value.
//% * **stop**: A pointer to a boolean that when set stops the enumeration.
//% **/
-//%- (void)enumerateRawValuesWithBlock:(void (^)(TYPE value, NSUInteger idx, BOOL *stop))block;
+//%- (void)enumerateRawValuesWithBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx, BOOL *stop))block;
//%
//%/**
//% * Enumerates the values on this array with the given block.
@@ -1791,7 +1791,7 @@
//% * **stop**: A pointer to a boolean that when set stops the enumeration.
//% **/
//%- (void)enumerateRawValuesWithOptions:(NSEnumerationOptions)opts
-//% usingBlock:(void (^)(TYPE value, NSUInteger idx, BOOL *stop))block;
+//% usingBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx, BOOL *stop))block;
//%
//%// If value is not a valid enumerator as defined by validationFunc, these
//%// methods will assert in debug, and will log in release and assign the value
@@ -1821,7 +1821,7 @@
//% * **idx**: The index of the current value.
//% * **stop**: A pointer to a boolean that when set stops the enumeration.
//% **/
-//%- (void)enumerateValuesWithBlock:(void (^)(TYPE value, NSUInteger idx, BOOL *stop))block;
+//%- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx, BOOL *stop))block;
//%
//%/**
//% * Enumerates the values on this array with the given block.
@@ -1833,7 +1833,7 @@
//% * **stop**: A pointer to a boolean that when set stops the enumeration.
//% **/
//%- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
-//% usingBlock:(void (^)(TYPE value, NSUInteger idx, BOOL *stop))block;
+//% usingBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx, BOOL *stop))block;
//%PDDM-DEFINE ARRAY_MUTABLE_INTERFACE(NAME, TYPE, HELPER_NAME)
//%/**
diff --git a/objectivec/GPBArray.m b/objectivec/GPBArray.m
index 122e030..5ce1e59 100644
--- a/objectivec/GPBArray.m
+++ b/objectivec/GPBArray.m
@@ -194,12 +194,12 @@
//% return result;
//%}
//%
-//%- (void)enumerate##ACCESSOR_NAME##ValuesWithBlock:(void (^)(TYPE value, NSUInteger idx, BOOL *stop))block {
+//%- (void)enumerate##ACCESSOR_NAME##ValuesWithBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx, BOOL *stop))block {
//% [self enumerate##ACCESSOR_NAME##ValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
//%}
//%
//%- (void)enumerate##ACCESSOR_NAME##ValuesWithOptions:(NSEnumerationOptions)opts
-//% ACCESSOR_NAME$S usingBlock:(void (^)(TYPE value, NSUInteger idx, BOOL *stop))block {
+//% ACCESSOR_NAME$S usingBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx, BOOL *stop))block {
//% // NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok).
//% BOOL stop = NO;
//% if ((opts & NSEnumerationReverse) == 0) {
@@ -405,12 +405,12 @@
return result;
}
-- (void)enumerateValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block {
+- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block {
[self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
- usingBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block {
+ usingBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block {
// NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok).
BOOL stop = NO;
if ((opts & NSEnumerationReverse) == 0) {
@@ -653,12 +653,12 @@
return result;
}
-- (void)enumerateValuesWithBlock:(void (^)(uint32_t value, NSUInteger idx, BOOL *stop))block {
+- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(uint32_t value, NSUInteger idx, BOOL *stop))block {
[self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
- usingBlock:(void (^)(uint32_t value, NSUInteger idx, BOOL *stop))block {
+ usingBlock:(void (NS_NOESCAPE ^)(uint32_t value, NSUInteger idx, BOOL *stop))block {
// NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok).
BOOL stop = NO;
if ((opts & NSEnumerationReverse) == 0) {
@@ -901,12 +901,12 @@
return result;
}
-- (void)enumerateValuesWithBlock:(void (^)(int64_t value, NSUInteger idx, BOOL *stop))block {
+- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int64_t value, NSUInteger idx, BOOL *stop))block {
[self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
- usingBlock:(void (^)(int64_t value, NSUInteger idx, BOOL *stop))block {
+ usingBlock:(void (NS_NOESCAPE ^)(int64_t value, NSUInteger idx, BOOL *stop))block {
// NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok).
BOOL stop = NO;
if ((opts & NSEnumerationReverse) == 0) {
@@ -1149,12 +1149,12 @@
return result;
}
-- (void)enumerateValuesWithBlock:(void (^)(uint64_t value, NSUInteger idx, BOOL *stop))block {
+- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(uint64_t value, NSUInteger idx, BOOL *stop))block {
[self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
- usingBlock:(void (^)(uint64_t value, NSUInteger idx, BOOL *stop))block {
+ usingBlock:(void (NS_NOESCAPE ^)(uint64_t value, NSUInteger idx, BOOL *stop))block {
// NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok).
BOOL stop = NO;
if ((opts & NSEnumerationReverse) == 0) {
@@ -1397,12 +1397,12 @@
return result;
}
-- (void)enumerateValuesWithBlock:(void (^)(float value, NSUInteger idx, BOOL *stop))block {
+- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(float value, NSUInteger idx, BOOL *stop))block {
[self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
- usingBlock:(void (^)(float value, NSUInteger idx, BOOL *stop))block {
+ usingBlock:(void (NS_NOESCAPE ^)(float value, NSUInteger idx, BOOL *stop))block {
// NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok).
BOOL stop = NO;
if ((opts & NSEnumerationReverse) == 0) {
@@ -1645,12 +1645,12 @@
return result;
}
-- (void)enumerateValuesWithBlock:(void (^)(double value, NSUInteger idx, BOOL *stop))block {
+- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(double value, NSUInteger idx, BOOL *stop))block {
[self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
- usingBlock:(void (^)(double value, NSUInteger idx, BOOL *stop))block {
+ usingBlock:(void (NS_NOESCAPE ^)(double value, NSUInteger idx, BOOL *stop))block {
// NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok).
BOOL stop = NO;
if ((opts & NSEnumerationReverse) == 0) {
@@ -1893,12 +1893,12 @@
return result;
}
-- (void)enumerateValuesWithBlock:(void (^)(BOOL value, NSUInteger idx, BOOL *stop))block {
+- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(BOOL value, NSUInteger idx, BOOL *stop))block {
[self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
- usingBlock:(void (^)(BOOL value, NSUInteger idx, BOOL *stop))block {
+ usingBlock:(void (NS_NOESCAPE ^)(BOOL value, NSUInteger idx, BOOL *stop))block {
// NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok).
BOOL stop = NO;
if ((opts & NSEnumerationReverse) == 0) {
@@ -2165,12 +2165,12 @@
return result;
}
-- (void)enumerateRawValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block {
+- (void)enumerateRawValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block {
[self enumerateRawValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateRawValuesWithOptions:(NSEnumerationOptions)opts
- usingBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block {
+ usingBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block {
// NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok).
BOOL stop = NO;
if ((opts & NSEnumerationReverse) == 0) {
@@ -2217,12 +2217,12 @@
return _values[index];
}
-- (void)enumerateValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block {
+- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block {
[self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block];
}
- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
- usingBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block {
+ usingBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block {
// NSEnumerationConcurrent isn't currently supported (and Apple's docs say that is ok).
BOOL stop = NO;
GPBEnumValidationFunc func = _validationFunc;