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