| OLD | NEW |
| 1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
| 2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 uint32_t bitMask = (1 << (idx % 32)); | 138 uint32_t bitMask = (1 << (idx % 32)); |
| 139 if (value) { | 139 if (value) { |
| 140 has_storage[byte] |= bitMask; | 140 has_storage[byte] |= bitMask; |
| 141 } else { | 141 } else { |
| 142 has_storage[byte] &= ~bitMask; | 142 has_storage[byte] &= ~bitMask; |
| 143 } | 143 } |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| 147 void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof, | 147 void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof, |
| 148 uint32_t fieldNumberNotToClear) { | 148 int32_t oneofHasIndex, uint32_t fieldNumberNotToClear) { |
| 149 int32_t hasIndex = oneof->oneofDescription_->index; | 149 uint32_t fieldNumberSet = GPBGetHasOneof(self, oneofHasIndex); |
| 150 uint32_t fieldNumberSet = GPBGetHasOneof(self, hasIndex); | |
| 151 if ((fieldNumberSet == fieldNumberNotToClear) || (fieldNumberSet == 0)) { | 150 if ((fieldNumberSet == fieldNumberNotToClear) || (fieldNumberSet == 0)) { |
| 152 // Do nothing/nothing set in the oneof. | 151 // Do nothing/nothing set in the oneof. |
| 153 return; | 152 return; |
| 154 } | 153 } |
| 155 | 154 |
| 156 // Like GPBClearMessageField(), free the memory if an objecttype is set, | 155 // Like GPBClearMessageField(), free the memory if an objecttype is set, |
| 157 // pod types don't need to do anything. | 156 // pod types don't need to do anything. |
| 158 GPBFieldDescriptor *fieldSet = [oneof fieldWithNumber:fieldNumberSet]; | 157 GPBFieldDescriptor *fieldSet = [oneof fieldWithNumber:fieldNumberSet]; |
| 159 NSCAssert(fieldSet, | 158 NSCAssert(fieldSet, |
| 160 @"%@: oneof set to something (%u) not in the oneof?", | 159 @"%@: oneof set to something (%u) not in the oneof?", |
| 161 [self class], fieldNumberSet); | 160 [self class], fieldNumberSet); |
| 162 if (fieldSet && GPBFieldStoresObject(fieldSet)) { | 161 if (fieldSet && GPBFieldStoresObject(fieldSet)) { |
| 163 uint8_t *storage = (uint8_t *)self->messageStorage_; | 162 uint8_t *storage = (uint8_t *)self->messageStorage_; |
| 164 id *typePtr = (id *)&storage[fieldSet->description_->offset]; | 163 id *typePtr = (id *)&storage[fieldSet->description_->offset]; |
| 165 [*typePtr release]; | 164 [*typePtr release]; |
| 166 *typePtr = nil; | 165 *typePtr = nil; |
| 167 } | 166 } |
| 168 | 167 |
| 169 // Set to nothing stored in the oneof. | 168 // Set to nothing stored in the oneof. |
| 170 // (field number doesn't matter since setting to nothing). | 169 // (field number doesn't matter since setting to nothing). |
| 171 GPBSetHasIvar(self, hasIndex, 1, NO); | 170 GPBSetHasIvar(self, oneofHasIndex, 1, NO); |
| 172 } | 171 } |
| 173 | 172 |
| 174 #pragma mark - IVar accessors | 173 #pragma mark - IVar accessors |
| 175 | 174 |
| 176 //%PDDM-DEFINE IVAR_POD_ACCESSORS_DEFN(NAME, TYPE) | 175 //%PDDM-DEFINE IVAR_POD_ACCESSORS_DEFN(NAME, TYPE) |
| 177 //%TYPE GPBGetMessage##NAME##Field(GPBMessage *self, | 176 //%TYPE GPBGetMessage##NAME##Field(GPBMessage *self, |
| 178 //% TYPE$S NAME$S GPBFieldDescriptor *field) { | 177 //% TYPE$S NAME$S GPBFieldDescriptor *field) { |
| 179 //% if (GPBGetHasIvarField(self, field)) { | 178 //% if (GPBGetHasIvarField(self, field)) { |
| 180 //% uint8_t *storage = (uint8_t *)self->messageStorage_; | 179 //% uint8_t *storage = (uint8_t *)self->messageStorage_; |
| 181 //% TYPE *typePtr = (TYPE *)&storage[field->description_->offset]; | 180 //% TYPE *typePtr = (TYPE *)&storage[field->description_->offset]; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 193 //% GPBFileSyntax syntax = [self descriptor].file.syntax; | 192 //% GPBFileSyntax syntax = [self descriptor].file.syntax; |
| 194 //% GPBSet##NAME##IvarWithFieldInternal(self, field, value, syntax); | 193 //% GPBSet##NAME##IvarWithFieldInternal(self, field, value, syntax); |
| 195 //%} | 194 //%} |
| 196 //% | 195 //% |
| 197 //%void GPBSet##NAME##IvarWithFieldInternal(GPBMessage *self, | 196 //%void GPBSet##NAME##IvarWithFieldInternal(GPBMessage *self, |
| 198 //% NAME$S GPBFieldDescriptor *field, | 197 //% NAME$S GPBFieldDescriptor *field, |
| 199 //% NAME$S TYPE value, | 198 //% NAME$S TYPE value, |
| 200 //% NAME$S GPBFileSyntax syntax) { | 199 //% NAME$S GPBFileSyntax syntax) { |
| 201 //% GPBOneofDescriptor *oneof = field->containingOneof_; | 200 //% GPBOneofDescriptor *oneof = field->containingOneof_; |
| 202 //% if (oneof) { | 201 //% if (oneof) { |
| 203 //% GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field)); | 202 //% GPBMessageFieldDescription *fieldDesc = field->description_; |
| 203 //% GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); |
| 204 //% } | 204 //% } |
| 205 //% NSCAssert(self->messageStorage_ != NULL, | 205 //% NSCAssert(self->messageStorage_ != NULL, |
| 206 //% @"%@: All messages should have storage (from init)", | 206 //% @"%@: All messages should have storage (from init)", |
| 207 //% [self class]); | 207 //% [self class]); |
| 208 //%#if defined(__clang_analyzer__) | 208 //%#if defined(__clang_analyzer__) |
| 209 //% if (self->messageStorage_ == NULL) return; | 209 //% if (self->messageStorage_ == NULL) return; |
| 210 //%#endif | 210 //%#endif |
| 211 //% uint8_t *storage = (uint8_t *)self->messageStorage_; | 211 //% uint8_t *storage = (uint8_t *)self->messageStorage_; |
| 212 //% TYPE *typePtr = (TYPE *)&storage[field->description_->offset]; | 212 //% TYPE *typePtr = (TYPE *)&storage[field->description_->offset]; |
| 213 //% *typePtr = value; | 213 //% *typePtr = value; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 className, hasSel, field.defaultValue.valueString); | 314 className, hasSel, field.defaultValue.valueString); |
| 315 // Note: valueString, depending on the type, it could easily be | 315 // Note: valueString, depending on the type, it could easily be |
| 316 // valueData/valueMessage. | 316 // valueData/valueMessage. |
| 317 } | 317 } |
| 318 #endif // DEBUG | 318 #endif // DEBUG |
| 319 if (!isMapOrArray) { | 319 if (!isMapOrArray) { |
| 320 // Non repeated/map can be in an oneof, clear any existing value from the | 320 // Non repeated/map can be in an oneof, clear any existing value from the |
| 321 // oneof. | 321 // oneof. |
| 322 GPBOneofDescriptor *oneof = field->containingOneof_; | 322 GPBOneofDescriptor *oneof = field->containingOneof_; |
| 323 if (oneof) { | 323 if (oneof) { |
| 324 GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field)); | 324 GPBMessageFieldDescription *fieldDesc = field->description_; |
| 325 GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); |
| 325 } | 326 } |
| 326 // Clear "has" if they are being set to nil. | 327 // Clear "has" if they are being set to nil. |
| 327 BOOL setHasValue = (value != nil); | 328 BOOL setHasValue = (value != nil); |
| 328 // Under proto3, Bytes & String fields get cleared by resetting them to | 329 // Under proto3, Bytes & String fields get cleared by resetting them to |
| 329 // their default (empty) values, so if they are set to something of length | 330 // their default (empty) values, so if they are set to something of length |
| 330 // zero, they are being cleared. | 331 // zero, they are being cleared. |
| 331 if ((syntax == GPBFileSyntaxProto3) && !fieldIsMessage && | 332 if ((syntax == GPBFileSyntaxProto3) && !fieldIsMessage && |
| 332 ([value length] == 0)) { | 333 ([value length] == 0)) { |
| 333 setHasValue = NO; | 334 setHasValue = NO; |
| 334 value = nil; | 335 value = nil; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 id *typePtr = (id *)&storage[field->description_->offset]; | 405 id *typePtr = (id *)&storage[field->description_->offset]; |
| 405 return *typePtr; | 406 return *typePtr; |
| 406 } | 407 } |
| 407 // Not set... | 408 // Not set... |
| 408 | 409 |
| 409 // Non messages (string/data), get their default. | 410 // Non messages (string/data), get their default. |
| 410 if (!GPBFieldDataTypeIsMessage(field)) { | 411 if (!GPBFieldDataTypeIsMessage(field)) { |
| 411 return field.defaultValue.valueMessage; | 412 return field.defaultValue.valueMessage; |
| 412 } | 413 } |
| 413 | 414 |
| 415 GPBPrepareReadOnlySemaphore(self); |
| 414 dispatch_semaphore_wait(self->readOnlySemaphore_, DISPATCH_TIME_FOREVER); | 416 dispatch_semaphore_wait(self->readOnlySemaphore_, DISPATCH_TIME_FOREVER); |
| 415 GPBMessage *result = GPBGetObjectIvarWithFieldNoAutocreate(self, field); | 417 GPBMessage *result = GPBGetObjectIvarWithFieldNoAutocreate(self, field); |
| 416 if (!result) { | 418 if (!result) { |
| 417 // For non repeated messages, create the object, set it and return it. | 419 // For non repeated messages, create the object, set it and return it. |
| 418 // This object will not initially be visible via GPBGetHasIvar, so | 420 // This object will not initially be visible via GPBGetHasIvar, so |
| 419 // we save its creator so it can become visible if it's mutated later. | 421 // we save its creator so it can become visible if it's mutated later. |
| 420 result = GPBCreateMessageWithAutocreator(field.msgClass, self, field); | 422 result = GPBCreateMessageWithAutocreator(field.msgClass, self, field); |
| 421 GPBSetAutocreatedRetainedObjectIvarWithField(self, field, result); | 423 GPBSetAutocreatedRetainedObjectIvarWithField(self, field, result); |
| 422 } | 424 } |
| 423 dispatch_semaphore_signal(self->readOnlySemaphore_); | 425 dispatch_semaphore_signal(self->readOnlySemaphore_); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 return result; | 471 return result; |
| 470 } | 472 } |
| 471 | 473 |
| 472 // Only exists for public api, no core code should use this. | 474 // Only exists for public api, no core code should use this. |
| 473 void GPBSetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field, | 475 void GPBSetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field, |
| 474 int32_t value) { | 476 int32_t value) { |
| 475 GPBFileSyntax syntax = [self descriptor].file.syntax; | 477 GPBFileSyntax syntax = [self descriptor].file.syntax; |
| 476 GPBSetInt32IvarWithFieldInternal(self, field, value, syntax); | 478 GPBSetInt32IvarWithFieldInternal(self, field, value, syntax); |
| 477 } | 479 } |
| 478 | 480 |
| 479 //%PDDM-EXPAND IVAR_POD_ACCESSORS_DEFN(Bool, BOOL) | |
| 480 // This block of code is generated, do not edit it directly. | |
| 481 | |
| 482 BOOL GPBGetMessageBoolField(GPBMessage *self, | 481 BOOL GPBGetMessageBoolField(GPBMessage *self, |
| 483 GPBFieldDescriptor *field) { | 482 GPBFieldDescriptor *field) { |
| 484 if (GPBGetHasIvarField(self, field)) { | 483 if (GPBGetHasIvarField(self, field)) { |
| 485 uint8_t *storage = (uint8_t *)self->messageStorage_; | 484 // Bools are stored in the has bits to avoid needing explicit space in the |
| 486 BOOL *typePtr = (BOOL *)&storage[field->description_->offset]; | 485 // storage structure. |
| 487 return *typePtr; | 486 // (the field number passed to the HasIvar helper doesn't really matter |
| 487 // since the offset is never negative) |
| 488 GPBMessageFieldDescription *fieldDesc = field->description_; |
| 489 return GPBGetHasIvar(self, (int32_t)(fieldDesc->offset), fieldDesc->number); |
| 488 } else { | 490 } else { |
| 489 return field.defaultValue.valueBool; | 491 return field.defaultValue.valueBool; |
| 490 } | 492 } |
| 491 } | 493 } |
| 492 | 494 |
| 493 // Only exists for public api, no core code should use this. | 495 // Only exists for public api, no core code should use this. |
| 494 void GPBSetMessageBoolField(GPBMessage *self, | 496 void GPBSetMessageBoolField(GPBMessage *self, |
| 495 GPBFieldDescriptor *field, | 497 GPBFieldDescriptor *field, |
| 496 BOOL value) { | 498 BOOL value) { |
| 497 if (self == nil || field == nil) return; | 499 if (self == nil || field == nil) return; |
| 498 GPBFileSyntax syntax = [self descriptor].file.syntax; | 500 GPBFileSyntax syntax = [self descriptor].file.syntax; |
| 499 GPBSetBoolIvarWithFieldInternal(self, field, value, syntax); | 501 GPBSetBoolIvarWithFieldInternal(self, field, value, syntax); |
| 500 } | 502 } |
| 501 | 503 |
| 502 void GPBSetBoolIvarWithFieldInternal(GPBMessage *self, | 504 void GPBSetBoolIvarWithFieldInternal(GPBMessage *self, |
| 503 GPBFieldDescriptor *field, | 505 GPBFieldDescriptor *field, |
| 504 BOOL value, | 506 BOOL value, |
| 505 GPBFileSyntax syntax) { | 507 GPBFileSyntax syntax) { |
| 508 GPBMessageFieldDescription *fieldDesc = field->description_; |
| 506 GPBOneofDescriptor *oneof = field->containingOneof_; | 509 GPBOneofDescriptor *oneof = field->containingOneof_; |
| 507 if (oneof) { | 510 if (oneof) { |
| 508 GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field)); | 511 GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); |
| 509 } | 512 } |
| 510 NSCAssert(self->messageStorage_ != NULL, | 513 |
| 511 @"%@: All messages should have storage (from init)", | 514 // Bools are stored in the has bits to avoid needing explicit space in the |
| 512 [self class]); | 515 // storage structure. |
| 513 #if defined(__clang_analyzer__) | 516 // (the field number passed to the HasIvar helper doesn't really matter since |
| 514 if (self->messageStorage_ == NULL) return; | 517 // the offset is never negative) |
| 515 #endif | 518 GPBSetHasIvar(self, (int32_t)(fieldDesc->offset), fieldDesc->number, value); |
| 516 uint8_t *storage = (uint8_t *)self->messageStorage_; | 519 |
| 517 BOOL *typePtr = (BOOL *)&storage[field->description_->offset]; | |
| 518 *typePtr = value; | |
| 519 // proto2: any value counts as having been set; proto3, it | 520 // proto2: any value counts as having been set; proto3, it |
| 520 // has to be a non zero value. | 521 // has to be a non zero value. |
| 521 BOOL hasValue = | 522 BOOL hasValue = |
| 522 (syntax == GPBFileSyntaxProto2) || (value != (BOOL)0); | 523 (syntax == GPBFileSyntaxProto2) || (value != (BOOL)0); |
| 523 GPBSetHasIvarField(self, field, hasValue); | 524 GPBSetHasIvarField(self, field, hasValue); |
| 524 GPBBecomeVisibleToAutocreator(self); | 525 GPBBecomeVisibleToAutocreator(self); |
| 525 } | 526 } |
| 526 | 527 |
| 527 //%PDDM-EXPAND IVAR_POD_ACCESSORS_DEFN(Int32, int32_t) | 528 //%PDDM-EXPAND IVAR_POD_ACCESSORS_DEFN(Int32, int32_t) |
| 528 // This block of code is generated, do not edit it directly. | 529 // This block of code is generated, do not edit it directly. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 546 GPBFileSyntax syntax = [self descriptor].file.syntax; | 547 GPBFileSyntax syntax = [self descriptor].file.syntax; |
| 547 GPBSetInt32IvarWithFieldInternal(self, field, value, syntax); | 548 GPBSetInt32IvarWithFieldInternal(self, field, value, syntax); |
| 548 } | 549 } |
| 549 | 550 |
| 550 void GPBSetInt32IvarWithFieldInternal(GPBMessage *self, | 551 void GPBSetInt32IvarWithFieldInternal(GPBMessage *self, |
| 551 GPBFieldDescriptor *field, | 552 GPBFieldDescriptor *field, |
| 552 int32_t value, | 553 int32_t value, |
| 553 GPBFileSyntax syntax) { | 554 GPBFileSyntax syntax) { |
| 554 GPBOneofDescriptor *oneof = field->containingOneof_; | 555 GPBOneofDescriptor *oneof = field->containingOneof_; |
| 555 if (oneof) { | 556 if (oneof) { |
| 556 GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field)); | 557 GPBMessageFieldDescription *fieldDesc = field->description_; |
| 558 GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); |
| 557 } | 559 } |
| 558 NSCAssert(self->messageStorage_ != NULL, | 560 NSCAssert(self->messageStorage_ != NULL, |
| 559 @"%@: All messages should have storage (from init)", | 561 @"%@: All messages should have storage (from init)", |
| 560 [self class]); | 562 [self class]); |
| 561 #if defined(__clang_analyzer__) | 563 #if defined(__clang_analyzer__) |
| 562 if (self->messageStorage_ == NULL) return; | 564 if (self->messageStorage_ == NULL) return; |
| 563 #endif | 565 #endif |
| 564 uint8_t *storage = (uint8_t *)self->messageStorage_; | 566 uint8_t *storage = (uint8_t *)self->messageStorage_; |
| 565 int32_t *typePtr = (int32_t *)&storage[field->description_->offset]; | 567 int32_t *typePtr = (int32_t *)&storage[field->description_->offset]; |
| 566 *typePtr = value; | 568 *typePtr = value; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 594 GPBFileSyntax syntax = [self descriptor].file.syntax; | 596 GPBFileSyntax syntax = [self descriptor].file.syntax; |
| 595 GPBSetUInt32IvarWithFieldInternal(self, field, value, syntax); | 597 GPBSetUInt32IvarWithFieldInternal(self, field, value, syntax); |
| 596 } | 598 } |
| 597 | 599 |
| 598 void GPBSetUInt32IvarWithFieldInternal(GPBMessage *self, | 600 void GPBSetUInt32IvarWithFieldInternal(GPBMessage *self, |
| 599 GPBFieldDescriptor *field, | 601 GPBFieldDescriptor *field, |
| 600 uint32_t value, | 602 uint32_t value, |
| 601 GPBFileSyntax syntax) { | 603 GPBFileSyntax syntax) { |
| 602 GPBOneofDescriptor *oneof = field->containingOneof_; | 604 GPBOneofDescriptor *oneof = field->containingOneof_; |
| 603 if (oneof) { | 605 if (oneof) { |
| 604 GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field)); | 606 GPBMessageFieldDescription *fieldDesc = field->description_; |
| 607 GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); |
| 605 } | 608 } |
| 606 NSCAssert(self->messageStorage_ != NULL, | 609 NSCAssert(self->messageStorage_ != NULL, |
| 607 @"%@: All messages should have storage (from init)", | 610 @"%@: All messages should have storage (from init)", |
| 608 [self class]); | 611 [self class]); |
| 609 #if defined(__clang_analyzer__) | 612 #if defined(__clang_analyzer__) |
| 610 if (self->messageStorage_ == NULL) return; | 613 if (self->messageStorage_ == NULL) return; |
| 611 #endif | 614 #endif |
| 612 uint8_t *storage = (uint8_t *)self->messageStorage_; | 615 uint8_t *storage = (uint8_t *)self->messageStorage_; |
| 613 uint32_t *typePtr = (uint32_t *)&storage[field->description_->offset]; | 616 uint32_t *typePtr = (uint32_t *)&storage[field->description_->offset]; |
| 614 *typePtr = value; | 617 *typePtr = value; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 642 GPBFileSyntax syntax = [self descriptor].file.syntax; | 645 GPBFileSyntax syntax = [self descriptor].file.syntax; |
| 643 GPBSetInt64IvarWithFieldInternal(self, field, value, syntax); | 646 GPBSetInt64IvarWithFieldInternal(self, field, value, syntax); |
| 644 } | 647 } |
| 645 | 648 |
| 646 void GPBSetInt64IvarWithFieldInternal(GPBMessage *self, | 649 void GPBSetInt64IvarWithFieldInternal(GPBMessage *self, |
| 647 GPBFieldDescriptor *field, | 650 GPBFieldDescriptor *field, |
| 648 int64_t value, | 651 int64_t value, |
| 649 GPBFileSyntax syntax) { | 652 GPBFileSyntax syntax) { |
| 650 GPBOneofDescriptor *oneof = field->containingOneof_; | 653 GPBOneofDescriptor *oneof = field->containingOneof_; |
| 651 if (oneof) { | 654 if (oneof) { |
| 652 GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field)); | 655 GPBMessageFieldDescription *fieldDesc = field->description_; |
| 656 GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); |
| 653 } | 657 } |
| 654 NSCAssert(self->messageStorage_ != NULL, | 658 NSCAssert(self->messageStorage_ != NULL, |
| 655 @"%@: All messages should have storage (from init)", | 659 @"%@: All messages should have storage (from init)", |
| 656 [self class]); | 660 [self class]); |
| 657 #if defined(__clang_analyzer__) | 661 #if defined(__clang_analyzer__) |
| 658 if (self->messageStorage_ == NULL) return; | 662 if (self->messageStorage_ == NULL) return; |
| 659 #endif | 663 #endif |
| 660 uint8_t *storage = (uint8_t *)self->messageStorage_; | 664 uint8_t *storage = (uint8_t *)self->messageStorage_; |
| 661 int64_t *typePtr = (int64_t *)&storage[field->description_->offset]; | 665 int64_t *typePtr = (int64_t *)&storage[field->description_->offset]; |
| 662 *typePtr = value; | 666 *typePtr = value; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 690 GPBFileSyntax syntax = [self descriptor].file.syntax; | 694 GPBFileSyntax syntax = [self descriptor].file.syntax; |
| 691 GPBSetUInt64IvarWithFieldInternal(self, field, value, syntax); | 695 GPBSetUInt64IvarWithFieldInternal(self, field, value, syntax); |
| 692 } | 696 } |
| 693 | 697 |
| 694 void GPBSetUInt64IvarWithFieldInternal(GPBMessage *self, | 698 void GPBSetUInt64IvarWithFieldInternal(GPBMessage *self, |
| 695 GPBFieldDescriptor *field, | 699 GPBFieldDescriptor *field, |
| 696 uint64_t value, | 700 uint64_t value, |
| 697 GPBFileSyntax syntax) { | 701 GPBFileSyntax syntax) { |
| 698 GPBOneofDescriptor *oneof = field->containingOneof_; | 702 GPBOneofDescriptor *oneof = field->containingOneof_; |
| 699 if (oneof) { | 703 if (oneof) { |
| 700 GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field)); | 704 GPBMessageFieldDescription *fieldDesc = field->description_; |
| 705 GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); |
| 701 } | 706 } |
| 702 NSCAssert(self->messageStorage_ != NULL, | 707 NSCAssert(self->messageStorage_ != NULL, |
| 703 @"%@: All messages should have storage (from init)", | 708 @"%@: All messages should have storage (from init)", |
| 704 [self class]); | 709 [self class]); |
| 705 #if defined(__clang_analyzer__) | 710 #if defined(__clang_analyzer__) |
| 706 if (self->messageStorage_ == NULL) return; | 711 if (self->messageStorage_ == NULL) return; |
| 707 #endif | 712 #endif |
| 708 uint8_t *storage = (uint8_t *)self->messageStorage_; | 713 uint8_t *storage = (uint8_t *)self->messageStorage_; |
| 709 uint64_t *typePtr = (uint64_t *)&storage[field->description_->offset]; | 714 uint64_t *typePtr = (uint64_t *)&storage[field->description_->offset]; |
| 710 *typePtr = value; | 715 *typePtr = value; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 738 GPBFileSyntax syntax = [self descriptor].file.syntax; | 743 GPBFileSyntax syntax = [self descriptor].file.syntax; |
| 739 GPBSetFloatIvarWithFieldInternal(self, field, value, syntax); | 744 GPBSetFloatIvarWithFieldInternal(self, field, value, syntax); |
| 740 } | 745 } |
| 741 | 746 |
| 742 void GPBSetFloatIvarWithFieldInternal(GPBMessage *self, | 747 void GPBSetFloatIvarWithFieldInternal(GPBMessage *self, |
| 743 GPBFieldDescriptor *field, | 748 GPBFieldDescriptor *field, |
| 744 float value, | 749 float value, |
| 745 GPBFileSyntax syntax) { | 750 GPBFileSyntax syntax) { |
| 746 GPBOneofDescriptor *oneof = field->containingOneof_; | 751 GPBOneofDescriptor *oneof = field->containingOneof_; |
| 747 if (oneof) { | 752 if (oneof) { |
| 748 GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field)); | 753 GPBMessageFieldDescription *fieldDesc = field->description_; |
| 754 GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); |
| 749 } | 755 } |
| 750 NSCAssert(self->messageStorage_ != NULL, | 756 NSCAssert(self->messageStorage_ != NULL, |
| 751 @"%@: All messages should have storage (from init)", | 757 @"%@: All messages should have storage (from init)", |
| 752 [self class]); | 758 [self class]); |
| 753 #if defined(__clang_analyzer__) | 759 #if defined(__clang_analyzer__) |
| 754 if (self->messageStorage_ == NULL) return; | 760 if (self->messageStorage_ == NULL) return; |
| 755 #endif | 761 #endif |
| 756 uint8_t *storage = (uint8_t *)self->messageStorage_; | 762 uint8_t *storage = (uint8_t *)self->messageStorage_; |
| 757 float *typePtr = (float *)&storage[field->description_->offset]; | 763 float *typePtr = (float *)&storage[field->description_->offset]; |
| 758 *typePtr = value; | 764 *typePtr = value; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 786 GPBFileSyntax syntax = [self descriptor].file.syntax; | 792 GPBFileSyntax syntax = [self descriptor].file.syntax; |
| 787 GPBSetDoubleIvarWithFieldInternal(self, field, value, syntax); | 793 GPBSetDoubleIvarWithFieldInternal(self, field, value, syntax); |
| 788 } | 794 } |
| 789 | 795 |
| 790 void GPBSetDoubleIvarWithFieldInternal(GPBMessage *self, | 796 void GPBSetDoubleIvarWithFieldInternal(GPBMessage *self, |
| 791 GPBFieldDescriptor *field, | 797 GPBFieldDescriptor *field, |
| 792 double value, | 798 double value, |
| 793 GPBFileSyntax syntax) { | 799 GPBFileSyntax syntax) { |
| 794 GPBOneofDescriptor *oneof = field->containingOneof_; | 800 GPBOneofDescriptor *oneof = field->containingOneof_; |
| 795 if (oneof) { | 801 if (oneof) { |
| 796 GPBMaybeClearOneof(self, oneof, GPBFieldNumber(field)); | 802 GPBMessageFieldDescription *fieldDesc = field->description_; |
| 803 GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); |
| 797 } | 804 } |
| 798 NSCAssert(self->messageStorage_ != NULL, | 805 NSCAssert(self->messageStorage_ != NULL, |
| 799 @"%@: All messages should have storage (from init)", | 806 @"%@: All messages should have storage (from init)", |
| 800 [self class]); | 807 [self class]); |
| 801 #if defined(__clang_analyzer__) | 808 #if defined(__clang_analyzer__) |
| 802 if (self->messageStorage_ == NULL) return; | 809 if (self->messageStorage_ == NULL) return; |
| 803 #endif | 810 #endif |
| 804 uint8_t *storage = (uint8_t *)self->messageStorage_; | 811 uint8_t *storage = (uint8_t *)self->messageStorage_; |
| 805 double *typePtr = (double *)&storage[field->description_->offset]; | 812 double *typePtr = (double *)&storage[field->description_->offset]; |
| 806 *typePtr = value; | 813 *typePtr = value; |
| 807 // proto2: any value counts as having been set; proto3, it | 814 // proto2: any value counts as having been set; proto3, it |
| 808 // has to be a non zero value. | 815 // has to be a non zero value. |
| 809 BOOL hasValue = | 816 BOOL hasValue = |
| 810 (syntax == GPBFileSyntaxProto2) || (value != (double)0); | 817 (syntax == GPBFileSyntaxProto2) || (value != (double)0); |
| 811 GPBSetHasIvarField(self, field, hasValue); | 818 GPBSetHasIvarField(self, field, hasValue); |
| 812 GPBBecomeVisibleToAutocreator(self); | 819 GPBBecomeVisibleToAutocreator(self); |
| 813 } | 820 } |
| 814 | 821 |
| 815 //%PDDM-EXPAND-END (7 expansions) | 822 //%PDDM-EXPAND-END (6 expansions) |
| 816 | 823 |
| 817 // Aliases are function calls that are virtually the same. | 824 // Aliases are function calls that are virtually the same. |
| 818 | 825 |
| 819 //%PDDM-EXPAND IVAR_ALIAS_DEFN_OBJECT(String, NSString) | 826 //%PDDM-EXPAND IVAR_ALIAS_DEFN_OBJECT(String, NSString) |
| 820 // This block of code is generated, do not edit it directly. | 827 // This block of code is generated, do not edit it directly. |
| 821 | 828 |
| 822 // Only exists for public api, no core code should use this. | 829 // Only exists for public api, no core code should use this. |
| 823 NSString *GPBGetMessageStringField(GPBMessage *self, | 830 NSString *GPBGetMessageStringField(GPBMessage *self, |
| 824 GPBFieldDescriptor *field) { | 831 GPBFieldDescriptor *field) { |
| 825 return (NSString *)GPBGetObjectIvarWithField(self, field); | 832 return (NSString *)GPBGetObjectIvarWithField(self, field); |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1246 } | 1253 } |
| 1247 | 1254 |
| 1248 NSString *lineEnding = @""; | 1255 NSString *lineEnding = @""; |
| 1249 | 1256 |
| 1250 // If the name can't be reversed or support for extra info was turned off, | 1257 // If the name can't be reversed or support for extra info was turned off, |
| 1251 // this can return nil. | 1258 // this can return nil. |
| 1252 NSString *fieldName = [field textFormatName]; | 1259 NSString *fieldName = [field textFormatName]; |
| 1253 if ([fieldName length] == 0) { | 1260 if ([fieldName length] == 0) { |
| 1254 fieldName = [NSString stringWithFormat:@"%u", GPBFieldNumber(field)]; | 1261 fieldName = [NSString stringWithFormat:@"%u", GPBFieldNumber(field)]; |
| 1255 // If there is only one entry, put the objc name as a comment, other wise | 1262 // If there is only one entry, put the objc name as a comment, other wise |
| 1256 // add it before the the repeated values. | 1263 // add it before the repeated values. |
| 1257 if (count > 1) { | 1264 if (count > 1) { |
| 1258 [toStr appendFormat:@"%@# %@\n", lineIndent, field.name]; | 1265 [toStr appendFormat:@"%@# %@\n", lineIndent, field.name]; |
| 1259 } else { | 1266 } else { |
| 1260 lineEnding = [NSString stringWithFormat:@" # %@", field.name]; | 1267 lineEnding = [NSString stringWithFormat:@" # %@", field.name]; |
| 1261 } | 1268 } |
| 1262 } | 1269 } |
| 1263 | 1270 |
| 1264 if (fieldType == GPBFieldTypeMap) { | 1271 if (fieldType == GPBFieldTypeMap) { |
| 1265 AppendTextFormatForMapMessageField(arrayOrMap, field, toStr, lineIndent, | 1272 AppendTextFormatForMapMessageField(arrayOrMap, field, toStr, lineIndent, |
| 1266 fieldName, lineEnding); | 1273 fieldName, lineEnding); |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1701 | 1708 |
| 1702 #pragma mark - GPBMessageSignatureProtocol | 1709 #pragma mark - GPBMessageSignatureProtocol |
| 1703 | 1710 |
| 1704 // A series of selectors that are used solely to get @encoding values | 1711 // A series of selectors that are used solely to get @encoding values |
| 1705 // for them by the dynamic protobuf runtime code. An object using the protocol | 1712 // for them by the dynamic protobuf runtime code. An object using the protocol |
| 1706 // needs to be declared for the protocol to be valid at runtime. | 1713 // needs to be declared for the protocol to be valid at runtime. |
| 1707 @interface GPBMessageSignatureProtocol : NSObject<GPBMessageSignatureProtocol> | 1714 @interface GPBMessageSignatureProtocol : NSObject<GPBMessageSignatureProtocol> |
| 1708 @end | 1715 @end |
| 1709 @implementation GPBMessageSignatureProtocol | 1716 @implementation GPBMessageSignatureProtocol |
| 1710 @end | 1717 @end |
| OLD | NEW |