OLD | NEW |
1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
2 // Copyright 2015 Google Inc. All rights reserved. | 2 // Copyright 2015 Google Inc. All rights reserved. |
3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
4 // | 4 // |
5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
7 // met: | 7 // met: |
8 // | 8 // |
9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
(...skipping 14 matching lines...) Expand all Loading... |
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 | 30 |
31 #import "GPBArray_PackagePrivate.h" | 31 #import "GPBArray_PackagePrivate.h" |
32 | 32 |
33 #import "GPBMessage_PackagePrivate.h" | 33 #import "GPBMessage_PackagePrivate.h" |
34 | 34 |
| 35 // Direct access is use for speed, to avoid even internally declaring things |
| 36 // read/write, etc. The warning is enabled in the project to ensure code calling |
| 37 // protos can turn on -Wdirect-ivar-access without issues. |
| 38 #pragma clang diagnostic push |
| 39 #pragma clang diagnostic ignored "-Wdirect-ivar-access" |
| 40 |
35 // Mutable arrays use an internal buffer that can always hold a multiple of this
elements. | 41 // Mutable arrays use an internal buffer that can always hold a multiple of this
elements. |
36 #define kChunkSize 16 | 42 #define kChunkSize 16 |
37 #define CapacityFromCount(x) (((x / kChunkSize) + 1) * kChunkSize) | 43 #define CapacityFromCount(x) (((x / kChunkSize) + 1) * kChunkSize) |
38 | 44 |
39 static BOOL ArrayDefault_IsValidValue(int32_t value) { | 45 static BOOL ArrayDefault_IsValidValue(int32_t value) { |
40 // Anything but the bad value marker is allowed. | 46 // Anything but the bad value marker is allowed. |
41 return (value != kGPBUnrecognizedEnumeratorValue); | 47 return (value != kGPBUnrecognizedEnumeratorValue); |
42 } | 48 } |
43 | 49 |
44 //%PDDM-DEFINE VALIDATE_RANGE(INDEX, COUNT) | 50 //%PDDM-DEFINE VALIDATE_RANGE(INDEX, COUNT) |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 157 |
152 //%PDDM-DEFINE ARRAY_IMMUTABLE_CORE(NAME, TYPE, ACCESSOR_NAME, FORMAT) | 158 //%PDDM-DEFINE ARRAY_IMMUTABLE_CORE(NAME, TYPE, ACCESSOR_NAME, FORMAT) |
153 //%- (void)dealloc { | 159 //%- (void)dealloc { |
154 //% NSAssert(!_autocreator, | 160 //% NSAssert(!_autocreator, |
155 //% @"%@: Autocreator must be cleared before release, autocreator: %@"
, | 161 //% @"%@: Autocreator must be cleared before release, autocreator: %@"
, |
156 //% [self class], _autocreator); | 162 //% [self class], _autocreator); |
157 //% free(_values); | 163 //% free(_values); |
158 //% [super dealloc]; | 164 //% [super dealloc]; |
159 //%} | 165 //%} |
160 //% | 166 //% |
161 //%- (BOOL)isEqual:(GPB##NAME##Array *)other { | 167 //%- (BOOL)isEqual:(id)other { |
162 //% if (self == other) { | 168 //% if (self == other) { |
163 //% return YES; | 169 //% return YES; |
164 //% } | 170 //% } |
165 //% if (![other isKindOfClass:[GPB##NAME##Array class]]) { | 171 //% if (![other isKindOfClass:[GPB##NAME##Array class]]) { |
166 //% return NO; | 172 //% return NO; |
167 //% } | 173 //% } |
168 //% return (_count == other->_count | 174 //% GPB##NAME##Array *otherArray = other; |
169 //% && memcmp(_values, other->_values, (_count * sizeof(TYPE))) == 0); | 175 //% return (_count == otherArray->_count |
| 176 //% && memcmp(_values, otherArray->_values, (_count * sizeof(TYPE))) ==
0); |
170 //%} | 177 //%} |
171 //% | 178 //% |
172 //%- (NSUInteger)hash { | 179 //%- (NSUInteger)hash { |
173 //% // Follow NSArray's lead, and use the count as the hash. | 180 //% // Follow NSArray's lead, and use the count as the hash. |
174 //% return _count; | 181 //% return _count; |
175 //%} | 182 //%} |
176 //% | 183 //% |
177 //%- (NSString *)description { | 184 //%- (NSString *)description { |
178 //% NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ",
[self class], self]; | 185 //% NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ",
[self class], self]; |
179 //% for (NSUInteger i = 0, count = _count; i < count; ++i) { | 186 //% for (NSUInteger i = 0, count = _count; i < count; ++i) { |
180 //% if (i == 0) { | 187 //% if (i == 0) { |
181 //% [result appendFormat:@"##FORMAT##", _values[i]]; | 188 //% [result appendFormat:@"##FORMAT##", _values[i]]; |
182 //% } else { | 189 //% } else { |
183 //% [result appendFormat:@", ##FORMAT##", _values[i]]; | 190 //% [result appendFormat:@", ##FORMAT##", _values[i]]; |
184 //% } | 191 //% } |
185 //% } | 192 //% } |
186 //% [result appendFormat:@" }"]; | 193 //% [result appendFormat:@" }"]; |
187 //% return result; | 194 //% return result; |
188 //%} | 195 //%} |
189 //% | 196 //% |
190 //%- (void)enumerate##ACCESSOR_NAME##ValuesWithBlock:(void (^)(TYPE value, NSUIn
teger idx, BOOL *stop))block { | 197 //%- (void)enumerate##ACCESSOR_NAME##ValuesWithBlock:(void (^)(TYPE value, NSUIn
teger idx, BOOL *stop))block { |
191 //% [self enumerate##ACCESSOR_NAME##ValuesWithOptions:0 usingBlock:block]; | 198 //% [self enumerate##ACCESSOR_NAME##ValuesWithOptions:(NSEnumerationOptions)0 u
singBlock:block]; |
192 //%} | 199 //%} |
193 //% | 200 //% |
194 //%- (void)enumerate##ACCESSOR_NAME##ValuesWithOptions:(NSEnumerationOptions)opt
s | 201 //%- (void)enumerate##ACCESSOR_NAME##ValuesWithOptions:(NSEnumerationOptions)opt
s |
195 //% ACCESSOR_NAME$S usingBlock:(void (^)(TYPE value, NSUIn
teger idx, BOOL *stop))block { | 202 //% ACCESSOR_NAME$S usingBlock:(void (^)(TYPE value, NSUIn
teger idx, BOOL *stop))block { |
196 //% // NSEnumerationConcurrent isn't currently supported (and Apple's docs say
that is ok). | 203 //% // NSEnumerationConcurrent isn't currently supported (and Apple's docs say
that is ok). |
197 //% BOOL stop = NO; | 204 //% BOOL stop = NO; |
198 //% if ((opts & NSEnumerationReverse) == 0) { | 205 //% if ((opts & NSEnumerationReverse) == 0) { |
199 //% for (NSUInteger i = 0, count = _count; i < count; ++i) { | 206 //% for (NSUInteger i = 0, count = _count; i < count; ++i) { |
200 //% block(_values[i], i, &stop); | 207 //% block(_values[i], i, &stop); |
201 //% if (stop) break; | 208 //% if (stop) break; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 } | 368 } |
362 | 369 |
363 - (void)dealloc { | 370 - (void)dealloc { |
364 NSAssert(!_autocreator, | 371 NSAssert(!_autocreator, |
365 @"%@: Autocreator must be cleared before release, autocreator: %@", | 372 @"%@: Autocreator must be cleared before release, autocreator: %@", |
366 [self class], _autocreator); | 373 [self class], _autocreator); |
367 free(_values); | 374 free(_values); |
368 [super dealloc]; | 375 [super dealloc]; |
369 } | 376 } |
370 | 377 |
371 - (BOOL)isEqual:(GPBInt32Array *)other { | 378 - (BOOL)isEqual:(id)other { |
372 if (self == other) { | 379 if (self == other) { |
373 return YES; | 380 return YES; |
374 } | 381 } |
375 if (![other isKindOfClass:[GPBInt32Array class]]) { | 382 if (![other isKindOfClass:[GPBInt32Array class]]) { |
376 return NO; | 383 return NO; |
377 } | 384 } |
378 return (_count == other->_count | 385 GPBInt32Array *otherArray = other; |
379 && memcmp(_values, other->_values, (_count * sizeof(int32_t))) == 0); | 386 return (_count == otherArray->_count |
| 387 && memcmp(_values, otherArray->_values, (_count * sizeof(int32_t))) ==
0); |
380 } | 388 } |
381 | 389 |
382 - (NSUInteger)hash { | 390 - (NSUInteger)hash { |
383 // Follow NSArray's lead, and use the count as the hash. | 391 // Follow NSArray's lead, and use the count as the hash. |
384 return _count; | 392 return _count; |
385 } | 393 } |
386 | 394 |
387 - (NSString *)description { | 395 - (NSString *)description { |
388 NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ", [se
lf class], self]; | 396 NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ", [se
lf class], self]; |
389 for (NSUInteger i = 0, count = _count; i < count; ++i) { | 397 for (NSUInteger i = 0, count = _count; i < count; ++i) { |
390 if (i == 0) { | 398 if (i == 0) { |
391 [result appendFormat:@"%d", _values[i]]; | 399 [result appendFormat:@"%d", _values[i]]; |
392 } else { | 400 } else { |
393 [result appendFormat:@", %d", _values[i]]; | 401 [result appendFormat:@", %d", _values[i]]; |
394 } | 402 } |
395 } | 403 } |
396 [result appendFormat:@" }"]; | 404 [result appendFormat:@" }"]; |
397 return result; | 405 return result; |
398 } | 406 } |
399 | 407 |
400 - (void)enumerateValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *
stop))block { | 408 - (void)enumerateValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *
stop))block { |
401 [self enumerateValuesWithOptions:0 usingBlock:block]; | 409 [self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block]; |
402 } | 410 } |
403 | 411 |
404 - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts | 412 - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts |
405 usingBlock:(void (^)(int32_t value, NSUInteger idx, BOOL
*stop))block { | 413 usingBlock:(void (^)(int32_t value, NSUInteger idx, BOOL
*stop))block { |
406 // NSEnumerationConcurrent isn't currently supported (and Apple's docs say tha
t is ok). | 414 // NSEnumerationConcurrent isn't currently supported (and Apple's docs say tha
t is ok). |
407 BOOL stop = NO; | 415 BOOL stop = NO; |
408 if ((opts & NSEnumerationReverse) == 0) { | 416 if ((opts & NSEnumerationReverse) == 0) { |
409 for (NSUInteger i = 0, count = _count; i < count; ++i) { | 417 for (NSUInteger i = 0, count = _count; i < count; ++i) { |
410 block(_values[i], i, &stop); | 418 block(_values[i], i, &stop); |
411 if (stop) break; | 419 if (stop) break; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 } | 616 } |
609 | 617 |
610 - (void)dealloc { | 618 - (void)dealloc { |
611 NSAssert(!_autocreator, | 619 NSAssert(!_autocreator, |
612 @"%@: Autocreator must be cleared before release, autocreator: %@", | 620 @"%@: Autocreator must be cleared before release, autocreator: %@", |
613 [self class], _autocreator); | 621 [self class], _autocreator); |
614 free(_values); | 622 free(_values); |
615 [super dealloc]; | 623 [super dealloc]; |
616 } | 624 } |
617 | 625 |
618 - (BOOL)isEqual:(GPBUInt32Array *)other { | 626 - (BOOL)isEqual:(id)other { |
619 if (self == other) { | 627 if (self == other) { |
620 return YES; | 628 return YES; |
621 } | 629 } |
622 if (![other isKindOfClass:[GPBUInt32Array class]]) { | 630 if (![other isKindOfClass:[GPBUInt32Array class]]) { |
623 return NO; | 631 return NO; |
624 } | 632 } |
625 return (_count == other->_count | 633 GPBUInt32Array *otherArray = other; |
626 && memcmp(_values, other->_values, (_count * sizeof(uint32_t))) == 0); | 634 return (_count == otherArray->_count |
| 635 && memcmp(_values, otherArray->_values, (_count * sizeof(uint32_t))) =
= 0); |
627 } | 636 } |
628 | 637 |
629 - (NSUInteger)hash { | 638 - (NSUInteger)hash { |
630 // Follow NSArray's lead, and use the count as the hash. | 639 // Follow NSArray's lead, and use the count as the hash. |
631 return _count; | 640 return _count; |
632 } | 641 } |
633 | 642 |
634 - (NSString *)description { | 643 - (NSString *)description { |
635 NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ", [se
lf class], self]; | 644 NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ", [se
lf class], self]; |
636 for (NSUInteger i = 0, count = _count; i < count; ++i) { | 645 for (NSUInteger i = 0, count = _count; i < count; ++i) { |
637 if (i == 0) { | 646 if (i == 0) { |
638 [result appendFormat:@"%u", _values[i]]; | 647 [result appendFormat:@"%u", _values[i]]; |
639 } else { | 648 } else { |
640 [result appendFormat:@", %u", _values[i]]; | 649 [result appendFormat:@", %u", _values[i]]; |
641 } | 650 } |
642 } | 651 } |
643 [result appendFormat:@" }"]; | 652 [result appendFormat:@" }"]; |
644 return result; | 653 return result; |
645 } | 654 } |
646 | 655 |
647 - (void)enumerateValuesWithBlock:(void (^)(uint32_t value, NSUInteger idx, BOOL
*stop))block { | 656 - (void)enumerateValuesWithBlock:(void (^)(uint32_t value, NSUInteger idx, BOOL
*stop))block { |
648 [self enumerateValuesWithOptions:0 usingBlock:block]; | 657 [self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block]; |
649 } | 658 } |
650 | 659 |
651 - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts | 660 - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts |
652 usingBlock:(void (^)(uint32_t value, NSUInteger idx, BOO
L *stop))block { | 661 usingBlock:(void (^)(uint32_t value, NSUInteger idx, BOO
L *stop))block { |
653 // NSEnumerationConcurrent isn't currently supported (and Apple's docs say tha
t is ok). | 662 // NSEnumerationConcurrent isn't currently supported (and Apple's docs say tha
t is ok). |
654 BOOL stop = NO; | 663 BOOL stop = NO; |
655 if ((opts & NSEnumerationReverse) == 0) { | 664 if ((opts & NSEnumerationReverse) == 0) { |
656 for (NSUInteger i = 0, count = _count; i < count; ++i) { | 665 for (NSUInteger i = 0, count = _count; i < count; ++i) { |
657 block(_values[i], i, &stop); | 666 block(_values[i], i, &stop); |
658 if (stop) break; | 667 if (stop) break; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 } | 864 } |
856 | 865 |
857 - (void)dealloc { | 866 - (void)dealloc { |
858 NSAssert(!_autocreator, | 867 NSAssert(!_autocreator, |
859 @"%@: Autocreator must be cleared before release, autocreator: %@", | 868 @"%@: Autocreator must be cleared before release, autocreator: %@", |
860 [self class], _autocreator); | 869 [self class], _autocreator); |
861 free(_values); | 870 free(_values); |
862 [super dealloc]; | 871 [super dealloc]; |
863 } | 872 } |
864 | 873 |
865 - (BOOL)isEqual:(GPBInt64Array *)other { | 874 - (BOOL)isEqual:(id)other { |
866 if (self == other) { | 875 if (self == other) { |
867 return YES; | 876 return YES; |
868 } | 877 } |
869 if (![other isKindOfClass:[GPBInt64Array class]]) { | 878 if (![other isKindOfClass:[GPBInt64Array class]]) { |
870 return NO; | 879 return NO; |
871 } | 880 } |
872 return (_count == other->_count | 881 GPBInt64Array *otherArray = other; |
873 && memcmp(_values, other->_values, (_count * sizeof(int64_t))) == 0); | 882 return (_count == otherArray->_count |
| 883 && memcmp(_values, otherArray->_values, (_count * sizeof(int64_t))) ==
0); |
874 } | 884 } |
875 | 885 |
876 - (NSUInteger)hash { | 886 - (NSUInteger)hash { |
877 // Follow NSArray's lead, and use the count as the hash. | 887 // Follow NSArray's lead, and use the count as the hash. |
878 return _count; | 888 return _count; |
879 } | 889 } |
880 | 890 |
881 - (NSString *)description { | 891 - (NSString *)description { |
882 NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ", [se
lf class], self]; | 892 NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ", [se
lf class], self]; |
883 for (NSUInteger i = 0, count = _count; i < count; ++i) { | 893 for (NSUInteger i = 0, count = _count; i < count; ++i) { |
884 if (i == 0) { | 894 if (i == 0) { |
885 [result appendFormat:@"%lld", _values[i]]; | 895 [result appendFormat:@"%lld", _values[i]]; |
886 } else { | 896 } else { |
887 [result appendFormat:@", %lld", _values[i]]; | 897 [result appendFormat:@", %lld", _values[i]]; |
888 } | 898 } |
889 } | 899 } |
890 [result appendFormat:@" }"]; | 900 [result appendFormat:@" }"]; |
891 return result; | 901 return result; |
892 } | 902 } |
893 | 903 |
894 - (void)enumerateValuesWithBlock:(void (^)(int64_t value, NSUInteger idx, BOOL *
stop))block { | 904 - (void)enumerateValuesWithBlock:(void (^)(int64_t value, NSUInteger idx, BOOL *
stop))block { |
895 [self enumerateValuesWithOptions:0 usingBlock:block]; | 905 [self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block]; |
896 } | 906 } |
897 | 907 |
898 - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts | 908 - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts |
899 usingBlock:(void (^)(int64_t value, NSUInteger idx, BOOL
*stop))block { | 909 usingBlock:(void (^)(int64_t value, NSUInteger idx, BOOL
*stop))block { |
900 // NSEnumerationConcurrent isn't currently supported (and Apple's docs say tha
t is ok). | 910 // NSEnumerationConcurrent isn't currently supported (and Apple's docs say tha
t is ok). |
901 BOOL stop = NO; | 911 BOOL stop = NO; |
902 if ((opts & NSEnumerationReverse) == 0) { | 912 if ((opts & NSEnumerationReverse) == 0) { |
903 for (NSUInteger i = 0, count = _count; i < count; ++i) { | 913 for (NSUInteger i = 0, count = _count; i < count; ++i) { |
904 block(_values[i], i, &stop); | 914 block(_values[i], i, &stop); |
905 if (stop) break; | 915 if (stop) break; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1102 } | 1112 } |
1103 | 1113 |
1104 - (void)dealloc { | 1114 - (void)dealloc { |
1105 NSAssert(!_autocreator, | 1115 NSAssert(!_autocreator, |
1106 @"%@: Autocreator must be cleared before release, autocreator: %@", | 1116 @"%@: Autocreator must be cleared before release, autocreator: %@", |
1107 [self class], _autocreator); | 1117 [self class], _autocreator); |
1108 free(_values); | 1118 free(_values); |
1109 [super dealloc]; | 1119 [super dealloc]; |
1110 } | 1120 } |
1111 | 1121 |
1112 - (BOOL)isEqual:(GPBUInt64Array *)other { | 1122 - (BOOL)isEqual:(id)other { |
1113 if (self == other) { | 1123 if (self == other) { |
1114 return YES; | 1124 return YES; |
1115 } | 1125 } |
1116 if (![other isKindOfClass:[GPBUInt64Array class]]) { | 1126 if (![other isKindOfClass:[GPBUInt64Array class]]) { |
1117 return NO; | 1127 return NO; |
1118 } | 1128 } |
1119 return (_count == other->_count | 1129 GPBUInt64Array *otherArray = other; |
1120 && memcmp(_values, other->_values, (_count * sizeof(uint64_t))) == 0); | 1130 return (_count == otherArray->_count |
| 1131 && memcmp(_values, otherArray->_values, (_count * sizeof(uint64_t))) =
= 0); |
1121 } | 1132 } |
1122 | 1133 |
1123 - (NSUInteger)hash { | 1134 - (NSUInteger)hash { |
1124 // Follow NSArray's lead, and use the count as the hash. | 1135 // Follow NSArray's lead, and use the count as the hash. |
1125 return _count; | 1136 return _count; |
1126 } | 1137 } |
1127 | 1138 |
1128 - (NSString *)description { | 1139 - (NSString *)description { |
1129 NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ", [se
lf class], self]; | 1140 NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ", [se
lf class], self]; |
1130 for (NSUInteger i = 0, count = _count; i < count; ++i) { | 1141 for (NSUInteger i = 0, count = _count; i < count; ++i) { |
1131 if (i == 0) { | 1142 if (i == 0) { |
1132 [result appendFormat:@"%llu", _values[i]]; | 1143 [result appendFormat:@"%llu", _values[i]]; |
1133 } else { | 1144 } else { |
1134 [result appendFormat:@", %llu", _values[i]]; | 1145 [result appendFormat:@", %llu", _values[i]]; |
1135 } | 1146 } |
1136 } | 1147 } |
1137 [result appendFormat:@" }"]; | 1148 [result appendFormat:@" }"]; |
1138 return result; | 1149 return result; |
1139 } | 1150 } |
1140 | 1151 |
1141 - (void)enumerateValuesWithBlock:(void (^)(uint64_t value, NSUInteger idx, BOOL
*stop))block { | 1152 - (void)enumerateValuesWithBlock:(void (^)(uint64_t value, NSUInteger idx, BOOL
*stop))block { |
1142 [self enumerateValuesWithOptions:0 usingBlock:block]; | 1153 [self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block]; |
1143 } | 1154 } |
1144 | 1155 |
1145 - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts | 1156 - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts |
1146 usingBlock:(void (^)(uint64_t value, NSUInteger idx, BOO
L *stop))block { | 1157 usingBlock:(void (^)(uint64_t value, NSUInteger idx, BOO
L *stop))block { |
1147 // NSEnumerationConcurrent isn't currently supported (and Apple's docs say tha
t is ok). | 1158 // NSEnumerationConcurrent isn't currently supported (and Apple's docs say tha
t is ok). |
1148 BOOL stop = NO; | 1159 BOOL stop = NO; |
1149 if ((opts & NSEnumerationReverse) == 0) { | 1160 if ((opts & NSEnumerationReverse) == 0) { |
1150 for (NSUInteger i = 0, count = _count; i < count; ++i) { | 1161 for (NSUInteger i = 0, count = _count; i < count; ++i) { |
1151 block(_values[i], i, &stop); | 1162 block(_values[i], i, &stop); |
1152 if (stop) break; | 1163 if (stop) break; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1349 } | 1360 } |
1350 | 1361 |
1351 - (void)dealloc { | 1362 - (void)dealloc { |
1352 NSAssert(!_autocreator, | 1363 NSAssert(!_autocreator, |
1353 @"%@: Autocreator must be cleared before release, autocreator: %@", | 1364 @"%@: Autocreator must be cleared before release, autocreator: %@", |
1354 [self class], _autocreator); | 1365 [self class], _autocreator); |
1355 free(_values); | 1366 free(_values); |
1356 [super dealloc]; | 1367 [super dealloc]; |
1357 } | 1368 } |
1358 | 1369 |
1359 - (BOOL)isEqual:(GPBFloatArray *)other { | 1370 - (BOOL)isEqual:(id)other { |
1360 if (self == other) { | 1371 if (self == other) { |
1361 return YES; | 1372 return YES; |
1362 } | 1373 } |
1363 if (![other isKindOfClass:[GPBFloatArray class]]) { | 1374 if (![other isKindOfClass:[GPBFloatArray class]]) { |
1364 return NO; | 1375 return NO; |
1365 } | 1376 } |
1366 return (_count == other->_count | 1377 GPBFloatArray *otherArray = other; |
1367 && memcmp(_values, other->_values, (_count * sizeof(float))) == 0); | 1378 return (_count == otherArray->_count |
| 1379 && memcmp(_values, otherArray->_values, (_count * sizeof(float))) == 0
); |
1368 } | 1380 } |
1369 | 1381 |
1370 - (NSUInteger)hash { | 1382 - (NSUInteger)hash { |
1371 // Follow NSArray's lead, and use the count as the hash. | 1383 // Follow NSArray's lead, and use the count as the hash. |
1372 return _count; | 1384 return _count; |
1373 } | 1385 } |
1374 | 1386 |
1375 - (NSString *)description { | 1387 - (NSString *)description { |
1376 NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ", [se
lf class], self]; | 1388 NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ", [se
lf class], self]; |
1377 for (NSUInteger i = 0, count = _count; i < count; ++i) { | 1389 for (NSUInteger i = 0, count = _count; i < count; ++i) { |
1378 if (i == 0) { | 1390 if (i == 0) { |
1379 [result appendFormat:@"%f", _values[i]]; | 1391 [result appendFormat:@"%f", _values[i]]; |
1380 } else { | 1392 } else { |
1381 [result appendFormat:@", %f", _values[i]]; | 1393 [result appendFormat:@", %f", _values[i]]; |
1382 } | 1394 } |
1383 } | 1395 } |
1384 [result appendFormat:@" }"]; | 1396 [result appendFormat:@" }"]; |
1385 return result; | 1397 return result; |
1386 } | 1398 } |
1387 | 1399 |
1388 - (void)enumerateValuesWithBlock:(void (^)(float value, NSUInteger idx, BOOL *st
op))block { | 1400 - (void)enumerateValuesWithBlock:(void (^)(float value, NSUInteger idx, BOOL *st
op))block { |
1389 [self enumerateValuesWithOptions:0 usingBlock:block]; | 1401 [self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block]; |
1390 } | 1402 } |
1391 | 1403 |
1392 - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts | 1404 - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts |
1393 usingBlock:(void (^)(float value, NSUInteger idx, BOOL *
stop))block { | 1405 usingBlock:(void (^)(float value, NSUInteger idx, BOOL *
stop))block { |
1394 // NSEnumerationConcurrent isn't currently supported (and Apple's docs say tha
t is ok). | 1406 // NSEnumerationConcurrent isn't currently supported (and Apple's docs say tha
t is ok). |
1395 BOOL stop = NO; | 1407 BOOL stop = NO; |
1396 if ((opts & NSEnumerationReverse) == 0) { | 1408 if ((opts & NSEnumerationReverse) == 0) { |
1397 for (NSUInteger i = 0, count = _count; i < count; ++i) { | 1409 for (NSUInteger i = 0, count = _count; i < count; ++i) { |
1398 block(_values[i], i, &stop); | 1410 block(_values[i], i, &stop); |
1399 if (stop) break; | 1411 if (stop) break; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1596 } | 1608 } |
1597 | 1609 |
1598 - (void)dealloc { | 1610 - (void)dealloc { |
1599 NSAssert(!_autocreator, | 1611 NSAssert(!_autocreator, |
1600 @"%@: Autocreator must be cleared before release, autocreator: %@", | 1612 @"%@: Autocreator must be cleared before release, autocreator: %@", |
1601 [self class], _autocreator); | 1613 [self class], _autocreator); |
1602 free(_values); | 1614 free(_values); |
1603 [super dealloc]; | 1615 [super dealloc]; |
1604 } | 1616 } |
1605 | 1617 |
1606 - (BOOL)isEqual:(GPBDoubleArray *)other { | 1618 - (BOOL)isEqual:(id)other { |
1607 if (self == other) { | 1619 if (self == other) { |
1608 return YES; | 1620 return YES; |
1609 } | 1621 } |
1610 if (![other isKindOfClass:[GPBDoubleArray class]]) { | 1622 if (![other isKindOfClass:[GPBDoubleArray class]]) { |
1611 return NO; | 1623 return NO; |
1612 } | 1624 } |
1613 return (_count == other->_count | 1625 GPBDoubleArray *otherArray = other; |
1614 && memcmp(_values, other->_values, (_count * sizeof(double))) == 0); | 1626 return (_count == otherArray->_count |
| 1627 && memcmp(_values, otherArray->_values, (_count * sizeof(double))) ==
0); |
1615 } | 1628 } |
1616 | 1629 |
1617 - (NSUInteger)hash { | 1630 - (NSUInteger)hash { |
1618 // Follow NSArray's lead, and use the count as the hash. | 1631 // Follow NSArray's lead, and use the count as the hash. |
1619 return _count; | 1632 return _count; |
1620 } | 1633 } |
1621 | 1634 |
1622 - (NSString *)description { | 1635 - (NSString *)description { |
1623 NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ", [se
lf class], self]; | 1636 NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ", [se
lf class], self]; |
1624 for (NSUInteger i = 0, count = _count; i < count; ++i) { | 1637 for (NSUInteger i = 0, count = _count; i < count; ++i) { |
1625 if (i == 0) { | 1638 if (i == 0) { |
1626 [result appendFormat:@"%lf", _values[i]]; | 1639 [result appendFormat:@"%lf", _values[i]]; |
1627 } else { | 1640 } else { |
1628 [result appendFormat:@", %lf", _values[i]]; | 1641 [result appendFormat:@", %lf", _values[i]]; |
1629 } | 1642 } |
1630 } | 1643 } |
1631 [result appendFormat:@" }"]; | 1644 [result appendFormat:@" }"]; |
1632 return result; | 1645 return result; |
1633 } | 1646 } |
1634 | 1647 |
1635 - (void)enumerateValuesWithBlock:(void (^)(double value, NSUInteger idx, BOOL *s
top))block { | 1648 - (void)enumerateValuesWithBlock:(void (^)(double value, NSUInteger idx, BOOL *s
top))block { |
1636 [self enumerateValuesWithOptions:0 usingBlock:block]; | 1649 [self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block]; |
1637 } | 1650 } |
1638 | 1651 |
1639 - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts | 1652 - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts |
1640 usingBlock:(void (^)(double value, NSUInteger idx, BOOL
*stop))block { | 1653 usingBlock:(void (^)(double value, NSUInteger idx, BOOL
*stop))block { |
1641 // NSEnumerationConcurrent isn't currently supported (and Apple's docs say tha
t is ok). | 1654 // NSEnumerationConcurrent isn't currently supported (and Apple's docs say tha
t is ok). |
1642 BOOL stop = NO; | 1655 BOOL stop = NO; |
1643 if ((opts & NSEnumerationReverse) == 0) { | 1656 if ((opts & NSEnumerationReverse) == 0) { |
1644 for (NSUInteger i = 0, count = _count; i < count; ++i) { | 1657 for (NSUInteger i = 0, count = _count; i < count; ++i) { |
1645 block(_values[i], i, &stop); | 1658 block(_values[i], i, &stop); |
1646 if (stop) break; | 1659 if (stop) break; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1843 } | 1856 } |
1844 | 1857 |
1845 - (void)dealloc { | 1858 - (void)dealloc { |
1846 NSAssert(!_autocreator, | 1859 NSAssert(!_autocreator, |
1847 @"%@: Autocreator must be cleared before release, autocreator: %@", | 1860 @"%@: Autocreator must be cleared before release, autocreator: %@", |
1848 [self class], _autocreator); | 1861 [self class], _autocreator); |
1849 free(_values); | 1862 free(_values); |
1850 [super dealloc]; | 1863 [super dealloc]; |
1851 } | 1864 } |
1852 | 1865 |
1853 - (BOOL)isEqual:(GPBBoolArray *)other { | 1866 - (BOOL)isEqual:(id)other { |
1854 if (self == other) { | 1867 if (self == other) { |
1855 return YES; | 1868 return YES; |
1856 } | 1869 } |
1857 if (![other isKindOfClass:[GPBBoolArray class]]) { | 1870 if (![other isKindOfClass:[GPBBoolArray class]]) { |
1858 return NO; | 1871 return NO; |
1859 } | 1872 } |
1860 return (_count == other->_count | 1873 GPBBoolArray *otherArray = other; |
1861 && memcmp(_values, other->_values, (_count * sizeof(BOOL))) == 0); | 1874 return (_count == otherArray->_count |
| 1875 && memcmp(_values, otherArray->_values, (_count * sizeof(BOOL))) == 0)
; |
1862 } | 1876 } |
1863 | 1877 |
1864 - (NSUInteger)hash { | 1878 - (NSUInteger)hash { |
1865 // Follow NSArray's lead, and use the count as the hash. | 1879 // Follow NSArray's lead, and use the count as the hash. |
1866 return _count; | 1880 return _count; |
1867 } | 1881 } |
1868 | 1882 |
1869 - (NSString *)description { | 1883 - (NSString *)description { |
1870 NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ", [se
lf class], self]; | 1884 NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ", [se
lf class], self]; |
1871 for (NSUInteger i = 0, count = _count; i < count; ++i) { | 1885 for (NSUInteger i = 0, count = _count; i < count; ++i) { |
1872 if (i == 0) { | 1886 if (i == 0) { |
1873 [result appendFormat:@"%d", _values[i]]; | 1887 [result appendFormat:@"%d", _values[i]]; |
1874 } else { | 1888 } else { |
1875 [result appendFormat:@", %d", _values[i]]; | 1889 [result appendFormat:@", %d", _values[i]]; |
1876 } | 1890 } |
1877 } | 1891 } |
1878 [result appendFormat:@" }"]; | 1892 [result appendFormat:@" }"]; |
1879 return result; | 1893 return result; |
1880 } | 1894 } |
1881 | 1895 |
1882 - (void)enumerateValuesWithBlock:(void (^)(BOOL value, NSUInteger idx, BOOL *sto
p))block { | 1896 - (void)enumerateValuesWithBlock:(void (^)(BOOL value, NSUInteger idx, BOOL *sto
p))block { |
1883 [self enumerateValuesWithOptions:0 usingBlock:block]; | 1897 [self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block]; |
1884 } | 1898 } |
1885 | 1899 |
1886 - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts | 1900 - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts |
1887 usingBlock:(void (^)(BOOL value, NSUInteger idx, BOOL *s
top))block { | 1901 usingBlock:(void (^)(BOOL value, NSUInteger idx, BOOL *s
top))block { |
1888 // NSEnumerationConcurrent isn't currently supported (and Apple's docs say tha
t is ok). | 1902 // NSEnumerationConcurrent isn't currently supported (and Apple's docs say tha
t is ok). |
1889 BOOL stop = NO; | 1903 BOOL stop = NO; |
1890 if ((opts & NSEnumerationReverse) == 0) { | 1904 if ((opts & NSEnumerationReverse) == 0) { |
1891 for (NSUInteger i = 0, count = _count; i < count; ++i) { | 1905 for (NSUInteger i = 0, count = _count; i < count; ++i) { |
1892 block(_values[i], i, &stop); | 1906 block(_values[i], i, &stop); |
1893 if (stop) break; | 1907 if (stop) break; |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2114 // This block of code is generated, do not edit it directly. | 2128 // This block of code is generated, do not edit it directly. |
2115 | 2129 |
2116 - (void)dealloc { | 2130 - (void)dealloc { |
2117 NSAssert(!_autocreator, | 2131 NSAssert(!_autocreator, |
2118 @"%@: Autocreator must be cleared before release, autocreator: %@", | 2132 @"%@: Autocreator must be cleared before release, autocreator: %@", |
2119 [self class], _autocreator); | 2133 [self class], _autocreator); |
2120 free(_values); | 2134 free(_values); |
2121 [super dealloc]; | 2135 [super dealloc]; |
2122 } | 2136 } |
2123 | 2137 |
2124 - (BOOL)isEqual:(GPBEnumArray *)other { | 2138 - (BOOL)isEqual:(id)other { |
2125 if (self == other) { | 2139 if (self == other) { |
2126 return YES; | 2140 return YES; |
2127 } | 2141 } |
2128 if (![other isKindOfClass:[GPBEnumArray class]]) { | 2142 if (![other isKindOfClass:[GPBEnumArray class]]) { |
2129 return NO; | 2143 return NO; |
2130 } | 2144 } |
2131 return (_count == other->_count | 2145 GPBEnumArray *otherArray = other; |
2132 && memcmp(_values, other->_values, (_count * sizeof(int32_t))) == 0); | 2146 return (_count == otherArray->_count |
| 2147 && memcmp(_values, otherArray->_values, (_count * sizeof(int32_t))) ==
0); |
2133 } | 2148 } |
2134 | 2149 |
2135 - (NSUInteger)hash { | 2150 - (NSUInteger)hash { |
2136 // Follow NSArray's lead, and use the count as the hash. | 2151 // Follow NSArray's lead, and use the count as the hash. |
2137 return _count; | 2152 return _count; |
2138 } | 2153 } |
2139 | 2154 |
2140 - (NSString *)description { | 2155 - (NSString *)description { |
2141 NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ", [se
lf class], self]; | 2156 NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p> { ", [se
lf class], self]; |
2142 for (NSUInteger i = 0, count = _count; i < count; ++i) { | 2157 for (NSUInteger i = 0, count = _count; i < count; ++i) { |
2143 if (i == 0) { | 2158 if (i == 0) { |
2144 [result appendFormat:@"%d", _values[i]]; | 2159 [result appendFormat:@"%d", _values[i]]; |
2145 } else { | 2160 } else { |
2146 [result appendFormat:@", %d", _values[i]]; | 2161 [result appendFormat:@", %d", _values[i]]; |
2147 } | 2162 } |
2148 } | 2163 } |
2149 [result appendFormat:@" }"]; | 2164 [result appendFormat:@" }"]; |
2150 return result; | 2165 return result; |
2151 } | 2166 } |
2152 | 2167 |
2153 - (void)enumerateRawValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOO
L *stop))block { | 2168 - (void)enumerateRawValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOO
L *stop))block { |
2154 [self enumerateRawValuesWithOptions:0 usingBlock:block]; | 2169 [self enumerateRawValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block]; |
2155 } | 2170 } |
2156 | 2171 |
2157 - (void)enumerateRawValuesWithOptions:(NSEnumerationOptions)opts | 2172 - (void)enumerateRawValuesWithOptions:(NSEnumerationOptions)opts |
2158 usingBlock:(void (^)(int32_t value, NSUInteger idx, B
OOL *stop))block { | 2173 usingBlock:(void (^)(int32_t value, NSUInteger idx, B
OOL *stop))block { |
2159 // NSEnumerationConcurrent isn't currently supported (and Apple's docs say tha
t is ok). | 2174 // NSEnumerationConcurrent isn't currently supported (and Apple's docs say tha
t is ok). |
2160 BOOL stop = NO; | 2175 BOOL stop = NO; |
2161 if ((opts & NSEnumerationReverse) == 0) { | 2176 if ((opts & NSEnumerationReverse) == 0) { |
2162 for (NSUInteger i = 0, count = _count; i < count; ++i) { | 2177 for (NSUInteger i = 0, count = _count; i < count; ++i) { |
2163 block(_values[i], i, &stop); | 2178 block(_values[i], i, &stop); |
2164 if (stop) break; | 2179 if (stop) break; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2196 if (index >= _count) { | 2211 if (index >= _count) { |
2197 [NSException raise:NSRangeException | 2212 [NSException raise:NSRangeException |
2198 format:@"Index (%lu) beyond bounds (%lu)", | 2213 format:@"Index (%lu) beyond bounds (%lu)", |
2199 (unsigned long)index, (unsigned long)_count]; | 2214 (unsigned long)index, (unsigned long)_count]; |
2200 } | 2215 } |
2201 //%PDDM-EXPAND-END VALIDATE_RANGE(index, _count) | 2216 //%PDDM-EXPAND-END VALIDATE_RANGE(index, _count) |
2202 return _values[index]; | 2217 return _values[index]; |
2203 } | 2218 } |
2204 | 2219 |
2205 - (void)enumerateValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *
stop))block { | 2220 - (void)enumerateValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *
stop))block { |
2206 [self enumerateValuesWithOptions:0 usingBlock:block]; | 2221 [self enumerateValuesWithOptions:(NSEnumerationOptions)0 usingBlock:block]; |
2207 } | 2222 } |
2208 | 2223 |
2209 - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts | 2224 - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts |
2210 usingBlock:(void (^)(int32_t value, NSUInteger idx, BOOL
*stop))block { | 2225 usingBlock:(void (^)(int32_t value, NSUInteger idx, BOOL
*stop))block { |
2211 // NSEnumerationConcurrent isn't currently supported (and Apple's docs say tha
t is ok). | 2226 // NSEnumerationConcurrent isn't currently supported (and Apple's docs say tha
t is ok). |
2212 BOOL stop = NO; | 2227 BOOL stop = NO; |
2213 GPBEnumValidationFunc func = _validationFunc; | 2228 GPBEnumValidationFunc func = _validationFunc; |
2214 if ((opts & NSEnumerationReverse) == 0) { | 2229 if ((opts & NSEnumerationReverse) == 0) { |
2215 int32_t *scan = _values; | 2230 int32_t *scan = _values; |
2216 int32_t *end = scan + _count; | 2231 int32_t *end = scan + _count; |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2525 - (void)enumerateObjectsUsingBlock:(void (^)(id obj, NSUInteger idx, BOOL *stop)
)block { | 2540 - (void)enumerateObjectsUsingBlock:(void (^)(id obj, NSUInteger idx, BOOL *stop)
)block { |
2526 [_array enumerateObjectsUsingBlock:block]; | 2541 [_array enumerateObjectsUsingBlock:block]; |
2527 } | 2542 } |
2528 | 2543 |
2529 - (void)enumerateObjectsWithOptions:(NSEnumerationOptions)opts | 2544 - (void)enumerateObjectsWithOptions:(NSEnumerationOptions)opts |
2530 usingBlock:(void (^)(id obj, NSUInteger idx, BOOL *stop
))block { | 2545 usingBlock:(void (^)(id obj, NSUInteger idx, BOOL *stop
))block { |
2531 [_array enumerateObjectsWithOptions:opts usingBlock:block]; | 2546 [_array enumerateObjectsWithOptions:opts usingBlock:block]; |
2532 } | 2547 } |
2533 | 2548 |
2534 @end | 2549 @end |
| 2550 |
| 2551 #pragma clang diagnostic pop |
OLD | NEW |