|
|
|
@ -267,17 +267,18 @@ void GPBClearMessageField(GPBMessage *self, GPBFieldDescriptor *field) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
GPBMessageFieldDescription *fieldDesc = field->description_; |
|
|
|
|
if (GPBFieldStoresObject(field)) { |
|
|
|
|
// Object types are handled slightly differently, they need to be released. |
|
|
|
|
uint8_t *storage = (uint8_t *)self->messageStorage_; |
|
|
|
|
id *typePtr = (id *)&storage[field->description_->offset]; |
|
|
|
|
id *typePtr = (id *)&storage[fieldDesc->offset]; |
|
|
|
|
[*typePtr release]; |
|
|
|
|
*typePtr = nil; |
|
|
|
|
} else { |
|
|
|
|
// POD types just need to clear the has bit as the Get* method will |
|
|
|
|
// fetch the default when needed. |
|
|
|
|
} |
|
|
|
|
GPBSetHasIvarField(self, field, NO); |
|
|
|
|
GPBSetHasIvar(self, fieldDesc->hasIndex, fieldDesc->number, NO); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
BOOL GPBGetHasIvar(GPBMessage *self, int32_t idx, uint32_t fieldNumber) { |
|
|
|
@ -356,6 +357,9 @@ void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof, |
|
|
|
|
//%TYPE GPBGetMessage##NAME##Field(GPBMessage *self, |
|
|
|
|
//% TYPE$S NAME$S GPBFieldDescriptor *field) { |
|
|
|
|
//%#if defined(DEBUG) && DEBUG |
|
|
|
|
//% NSCAssert([[self descriptor] fieldWithNumber:field.number] == field, |
|
|
|
|
//% @"FieldDescriptor %@ doesn't appear to be for %@ messages.", |
|
|
|
|
//% field.name, [self class]); |
|
|
|
|
//% NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field), |
|
|
|
|
//% GPBDataType##NAME), |
|
|
|
|
//% @"Attempting to get value of TYPE from field %@ " |
|
|
|
@ -377,15 +381,10 @@ void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof, |
|
|
|
|
//% NAME$S GPBFieldDescriptor *field, |
|
|
|
|
//% NAME$S TYPE value) { |
|
|
|
|
//% if (self == nil || field == nil) return; |
|
|
|
|
//% GPBFileSyntax syntax = [self descriptor].file.syntax; |
|
|
|
|
//% GPBSet##NAME##IvarWithFieldInternal(self, field, value, syntax); |
|
|
|
|
//%} |
|
|
|
|
//% |
|
|
|
|
//%void GPBSet##NAME##IvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
//% NAME$S GPBFieldDescriptor *field, |
|
|
|
|
//% NAME$S TYPE value, |
|
|
|
|
//% NAME$S GPBFileSyntax syntax) { |
|
|
|
|
//%#if defined(DEBUG) && DEBUG |
|
|
|
|
//% NSCAssert([[self descriptor] fieldWithNumber:field.number] == field, |
|
|
|
|
//% @"FieldDescriptor %@ doesn't appear to be for %@ messages.", |
|
|
|
|
//% field.name, [self class]); |
|
|
|
|
//% NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field), |
|
|
|
|
//% GPBDataType##NAME), |
|
|
|
|
//% @"Attempting to set field %@ of %@ which is of type %@ with " |
|
|
|
@ -393,9 +392,17 @@ void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof, |
|
|
|
|
//% [self class], field.name, |
|
|
|
|
//% TypeToString(GPBGetFieldDataType(field))); |
|
|
|
|
//%#endif |
|
|
|
|
//% GPBFileSyntax syntax = [self descriptor].file.syntax; |
|
|
|
|
//% GPBSet##NAME##IvarWithFieldInternal(self, field, value, syntax); |
|
|
|
|
//%} |
|
|
|
|
//% |
|
|
|
|
//%void GPBSet##NAME##IvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
//% NAME$S GPBFieldDescriptor *field, |
|
|
|
|
//% NAME$S TYPE value, |
|
|
|
|
//% NAME$S GPBFileSyntax syntax) { |
|
|
|
|
//% GPBOneofDescriptor *oneof = field->containingOneof_; |
|
|
|
|
//% GPBMessageFieldDescription *fieldDesc = field->description_; |
|
|
|
|
//% if (oneof) { |
|
|
|
|
//% GPBMessageFieldDescription *fieldDesc = field->description_; |
|
|
|
|
//% GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); |
|
|
|
|
//% } |
|
|
|
|
//%#if defined(DEBUG) && DEBUG |
|
|
|
@ -407,14 +414,14 @@ void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof, |
|
|
|
|
//% if (self->messageStorage_ == NULL) return; |
|
|
|
|
//%#endif |
|
|
|
|
//% uint8_t *storage = (uint8_t *)self->messageStorage_; |
|
|
|
|
//% TYPE *typePtr = (TYPE *)&storage[field->description_->offset]; |
|
|
|
|
//% TYPE *typePtr = (TYPE *)&storage[fieldDesc->offset]; |
|
|
|
|
//% *typePtr = value; |
|
|
|
|
//% // proto2: any value counts as having been set; proto3, it |
|
|
|
|
//% // has to be a non zero value or be in a oneof. |
|
|
|
|
//% BOOL hasValue = ((syntax == GPBFileSyntaxProto2) |
|
|
|
|
//% || (value != (TYPE)0) |
|
|
|
|
//% || (field->containingOneof_ != NULL)); |
|
|
|
|
//% GPBSetHasIvarField(self, field, hasValue); |
|
|
|
|
//% GPBSetHasIvar(self, fieldDesc->hasIndex, fieldDesc->number, hasValue); |
|
|
|
|
//% GPBBecomeVisibleToAutocreator(self); |
|
|
|
|
//%} |
|
|
|
|
//% |
|
|
|
@ -579,12 +586,12 @@ void GPBSetRetainedObjectIvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
// valueData/valueMessage. |
|
|
|
|
} |
|
|
|
|
#endif // DEBUG |
|
|
|
|
GPBMessageFieldDescription *fieldDesc = field->description_; |
|
|
|
|
if (!isMapOrArray) { |
|
|
|
|
// Non repeated/map can be in an oneof, clear any existing value from the |
|
|
|
|
// oneof. |
|
|
|
|
GPBOneofDescriptor *oneof = field->containingOneof_; |
|
|
|
|
if (oneof) { |
|
|
|
|
GPBMessageFieldDescription *fieldDesc = field->description_; |
|
|
|
|
GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); |
|
|
|
|
} |
|
|
|
|
// Clear "has" if they are being set to nil. |
|
|
|
@ -608,10 +615,10 @@ void GPBSetRetainedObjectIvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
value = nil; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
GPBSetHasIvarField(self, field, setHasValue); |
|
|
|
|
GPBSetHasIvar(self, fieldDesc->hasIndex, fieldDesc->number, setHasValue); |
|
|
|
|
} |
|
|
|
|
uint8_t *storage = (uint8_t *)self->messageStorage_; |
|
|
|
|
id *typePtr = (id *)&storage[field->description_->offset]; |
|
|
|
|
id *typePtr = (id *)&storage[fieldDesc->offset]; |
|
|
|
|
|
|
|
|
|
id oldValue = *typePtr; |
|
|
|
|
|
|
|
|
@ -678,6 +685,16 @@ id GPBGetObjectIvarWithFieldNoAutocreate(GPBMessage *self, |
|
|
|
|
|
|
|
|
|
// Only exists for public api, no core code should use this. |
|
|
|
|
int32_t GPBGetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field) { |
|
|
|
|
#if defined(DEBUG) && DEBUG |
|
|
|
|
NSCAssert([[self descriptor] fieldWithNumber:field.number] == field, |
|
|
|
|
@"FieldDescriptor %@ doesn't appear to be for %@ messages.", |
|
|
|
|
field.name, [self class]); |
|
|
|
|
NSCAssert(GPBGetFieldDataType(field) == GPBDataTypeEnum, |
|
|
|
|
@"Attempting to get value of type Enum from field %@ " |
|
|
|
|
@"of %@ which is of type %@.", |
|
|
|
|
[self class], field.name, |
|
|
|
|
TypeToString(GPBGetFieldDataType(field))); |
|
|
|
|
#endif |
|
|
|
|
GPBFileSyntax syntax = [self descriptor].file.syntax; |
|
|
|
|
return GPBGetEnumIvarWithFieldInternal(self, field, syntax); |
|
|
|
|
} |
|
|
|
@ -685,13 +702,6 @@ int32_t GPBGetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field) { |
|
|
|
|
int32_t GPBGetEnumIvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, |
|
|
|
|
GPBFileSyntax syntax) { |
|
|
|
|
#if defined(DEBUG) && DEBUG |
|
|
|
|
NSCAssert(GPBGetFieldDataType(field) == GPBDataTypeEnum, |
|
|
|
|
@"Attempting to get value of type Enum from field %@ " |
|
|
|
|
@"of %@ which is of type %@.", |
|
|
|
|
[self class], field.name, |
|
|
|
|
TypeToString(GPBGetFieldDataType(field))); |
|
|
|
|
#endif |
|
|
|
|
int32_t result = GPBGetMessageInt32Field(self, field); |
|
|
|
|
// If this is presevering unknown enums, make sure the value is valid before |
|
|
|
|
// returning it. |
|
|
|
@ -705,6 +715,16 @@ int32_t GPBGetEnumIvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
// Only exists for public api, no core code should use this. |
|
|
|
|
void GPBSetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field, |
|
|
|
|
int32_t value) { |
|
|
|
|
#if defined(DEBUG) && DEBUG |
|
|
|
|
NSCAssert([[self descriptor] fieldWithNumber:field.number] == field, |
|
|
|
|
@"FieldDescriptor %@ doesn't appear to be for %@ messages.", |
|
|
|
|
field.name, [self class]); |
|
|
|
|
NSCAssert(GPBGetFieldDataType(field) == GPBDataTypeEnum, |
|
|
|
|
@"Attempting to set field %@ of %@ which is of type %@ with " |
|
|
|
|
@"value of type Enum.", |
|
|
|
|
[self class], field.name, |
|
|
|
|
TypeToString(GPBGetFieldDataType(field))); |
|
|
|
|
#endif |
|
|
|
|
GPBFileSyntax syntax = [self descriptor].file.syntax; |
|
|
|
|
GPBSetInt32IvarWithFieldInternal(self, field, value, syntax); |
|
|
|
|
} |
|
|
|
@ -712,13 +732,6 @@ void GPBSetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field, |
|
|
|
|
void GPBSetEnumIvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, int32_t value, |
|
|
|
|
GPBFileSyntax syntax) { |
|
|
|
|
#if defined(DEBUG) && DEBUG |
|
|
|
|
NSCAssert(GPBGetFieldDataType(field) == GPBDataTypeEnum, |
|
|
|
|
@"Attempting to set field %@ of %@ which is of type %@ with " |
|
|
|
|
@"value of type Enum.", |
|
|
|
|
[self class], field.name, |
|
|
|
|
TypeToString(GPBGetFieldDataType(field))); |
|
|
|
|
#endif |
|
|
|
|
// Don't allow in unknown values. Proto3 can use the Raw method. |
|
|
|
|
if (![field isValidEnumValue:value]) { |
|
|
|
|
[NSException raise:NSInvalidArgumentException |
|
|
|
@ -745,6 +758,9 @@ void GPBSetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field, |
|
|
|
|
BOOL GPBGetMessageBoolField(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field) { |
|
|
|
|
#if defined(DEBUG) && DEBUG |
|
|
|
|
NSCAssert([[self descriptor] fieldWithNumber:field.number] == field, |
|
|
|
|
@"FieldDescriptor %@ doesn't appear to be for %@ messages.", |
|
|
|
|
field.name, [self class]); |
|
|
|
|
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field), GPBDataTypeBool), |
|
|
|
|
@"Attempting to get value of type bool from field %@ " |
|
|
|
|
@"of %@ which is of type %@.", |
|
|
|
@ -768,6 +784,16 @@ void GPBSetMessageBoolField(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, |
|
|
|
|
BOOL value) { |
|
|
|
|
if (self == nil || field == nil) return; |
|
|
|
|
#if defined(DEBUG) && DEBUG |
|
|
|
|
NSCAssert([[self descriptor] fieldWithNumber:field.number] == field, |
|
|
|
|
@"FieldDescriptor %@ doesn't appear to be for %@ messages.", |
|
|
|
|
field.name, [self class]); |
|
|
|
|
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field), GPBDataTypeBool), |
|
|
|
|
@"Attempting to set field %@ of %@ which is of type %@ with " |
|
|
|
|
@"value of type bool.", |
|
|
|
|
[self class], field.name, |
|
|
|
|
TypeToString(GPBGetFieldDataType(field))); |
|
|
|
|
#endif |
|
|
|
|
GPBFileSyntax syntax = [self descriptor].file.syntax; |
|
|
|
|
GPBSetBoolIvarWithFieldInternal(self, field, value, syntax); |
|
|
|
|
} |
|
|
|
@ -776,13 +802,6 @@ void GPBSetBoolIvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, |
|
|
|
|
BOOL value, |
|
|
|
|
GPBFileSyntax syntax) { |
|
|
|
|
#if defined(DEBUG) && DEBUG |
|
|
|
|
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field), GPBDataTypeBool), |
|
|
|
|
@"Attempting to set field %@ of %@ which is of type %@ with " |
|
|
|
|
@"value of type bool.", |
|
|
|
|
[self class], field.name, |
|
|
|
|
TypeToString(GPBGetFieldDataType(field))); |
|
|
|
|
#endif |
|
|
|
|
GPBMessageFieldDescription *fieldDesc = field->description_; |
|
|
|
|
GPBOneofDescriptor *oneof = field->containingOneof_; |
|
|
|
|
if (oneof) { |
|
|
|
@ -800,7 +819,7 @@ void GPBSetBoolIvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
BOOL hasValue = ((syntax == GPBFileSyntaxProto2) |
|
|
|
|
|| (value != (BOOL)0) |
|
|
|
|
|| (field->containingOneof_ != NULL)); |
|
|
|
|
GPBSetHasIvarField(self, field, hasValue); |
|
|
|
|
GPBSetHasIvar(self, fieldDesc->hasIndex, fieldDesc->number, hasValue); |
|
|
|
|
GPBBecomeVisibleToAutocreator(self); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -811,6 +830,9 @@ void GPBSetBoolIvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
int32_t GPBGetMessageInt32Field(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field) { |
|
|
|
|
#if defined(DEBUG) && DEBUG |
|
|
|
|
NSCAssert([[self descriptor] fieldWithNumber:field.number] == field, |
|
|
|
|
@"FieldDescriptor %@ doesn't appear to be for %@ messages.", |
|
|
|
|
field.name, [self class]); |
|
|
|
|
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field), |
|
|
|
|
GPBDataTypeInt32), |
|
|
|
|
@"Attempting to get value of int32_t from field %@ " |
|
|
|
@ -832,15 +854,10 @@ void GPBSetMessageInt32Field(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, |
|
|
|
|
int32_t value) { |
|
|
|
|
if (self == nil || field == nil) return; |
|
|
|
|
GPBFileSyntax syntax = [self descriptor].file.syntax; |
|
|
|
|
GPBSetInt32IvarWithFieldInternal(self, field, value, syntax); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void GPBSetInt32IvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, |
|
|
|
|
int32_t value, |
|
|
|
|
GPBFileSyntax syntax) { |
|
|
|
|
#if defined(DEBUG) && DEBUG |
|
|
|
|
NSCAssert([[self descriptor] fieldWithNumber:field.number] == field, |
|
|
|
|
@"FieldDescriptor %@ doesn't appear to be for %@ messages.", |
|
|
|
|
field.name, [self class]); |
|
|
|
|
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field), |
|
|
|
|
GPBDataTypeInt32), |
|
|
|
|
@"Attempting to set field %@ of %@ which is of type %@ with " |
|
|
|
@ -848,9 +865,17 @@ void GPBSetInt32IvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
[self class], field.name, |
|
|
|
|
TypeToString(GPBGetFieldDataType(field))); |
|
|
|
|
#endif |
|
|
|
|
GPBFileSyntax syntax = [self descriptor].file.syntax; |
|
|
|
|
GPBSetInt32IvarWithFieldInternal(self, field, value, syntax); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void GPBSetInt32IvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, |
|
|
|
|
int32_t value, |
|
|
|
|
GPBFileSyntax syntax) { |
|
|
|
|
GPBOneofDescriptor *oneof = field->containingOneof_; |
|
|
|
|
GPBMessageFieldDescription *fieldDesc = field->description_; |
|
|
|
|
if (oneof) { |
|
|
|
|
GPBMessageFieldDescription *fieldDesc = field->description_; |
|
|
|
|
GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); |
|
|
|
|
} |
|
|
|
|
#if defined(DEBUG) && DEBUG |
|
|
|
@ -862,14 +887,14 @@ void GPBSetInt32IvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
if (self->messageStorage_ == NULL) return; |
|
|
|
|
#endif |
|
|
|
|
uint8_t *storage = (uint8_t *)self->messageStorage_; |
|
|
|
|
int32_t *typePtr = (int32_t *)&storage[field->description_->offset]; |
|
|
|
|
int32_t *typePtr = (int32_t *)&storage[fieldDesc->offset]; |
|
|
|
|
*typePtr = value; |
|
|
|
|
// proto2: any value counts as having been set; proto3, it |
|
|
|
|
// has to be a non zero value or be in a oneof. |
|
|
|
|
BOOL hasValue = ((syntax == GPBFileSyntaxProto2) |
|
|
|
|
|| (value != (int32_t)0) |
|
|
|
|
|| (field->containingOneof_ != NULL)); |
|
|
|
|
GPBSetHasIvarField(self, field, hasValue); |
|
|
|
|
GPBSetHasIvar(self, fieldDesc->hasIndex, fieldDesc->number, hasValue); |
|
|
|
|
GPBBecomeVisibleToAutocreator(self); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -881,6 +906,9 @@ void GPBSetInt32IvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
uint32_t GPBGetMessageUInt32Field(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field) { |
|
|
|
|
#if defined(DEBUG) && DEBUG |
|
|
|
|
NSCAssert([[self descriptor] fieldWithNumber:field.number] == field, |
|
|
|
|
@"FieldDescriptor %@ doesn't appear to be for %@ messages.", |
|
|
|
|
field.name, [self class]); |
|
|
|
|
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field), |
|
|
|
|
GPBDataTypeUInt32), |
|
|
|
|
@"Attempting to get value of uint32_t from field %@ " |
|
|
|
@ -902,15 +930,10 @@ void GPBSetMessageUInt32Field(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, |
|
|
|
|
uint32_t value) { |
|
|
|
|
if (self == nil || field == nil) return; |
|
|
|
|
GPBFileSyntax syntax = [self descriptor].file.syntax; |
|
|
|
|
GPBSetUInt32IvarWithFieldInternal(self, field, value, syntax); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void GPBSetUInt32IvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, |
|
|
|
|
uint32_t value, |
|
|
|
|
GPBFileSyntax syntax) { |
|
|
|
|
#if defined(DEBUG) && DEBUG |
|
|
|
|
NSCAssert([[self descriptor] fieldWithNumber:field.number] == field, |
|
|
|
|
@"FieldDescriptor %@ doesn't appear to be for %@ messages.", |
|
|
|
|
field.name, [self class]); |
|
|
|
|
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field), |
|
|
|
|
GPBDataTypeUInt32), |
|
|
|
|
@"Attempting to set field %@ of %@ which is of type %@ with " |
|
|
|
@ -918,9 +941,17 @@ void GPBSetUInt32IvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
[self class], field.name, |
|
|
|
|
TypeToString(GPBGetFieldDataType(field))); |
|
|
|
|
#endif |
|
|
|
|
GPBFileSyntax syntax = [self descriptor].file.syntax; |
|
|
|
|
GPBSetUInt32IvarWithFieldInternal(self, field, value, syntax); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void GPBSetUInt32IvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, |
|
|
|
|
uint32_t value, |
|
|
|
|
GPBFileSyntax syntax) { |
|
|
|
|
GPBOneofDescriptor *oneof = field->containingOneof_; |
|
|
|
|
GPBMessageFieldDescription *fieldDesc = field->description_; |
|
|
|
|
if (oneof) { |
|
|
|
|
GPBMessageFieldDescription *fieldDesc = field->description_; |
|
|
|
|
GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); |
|
|
|
|
} |
|
|
|
|
#if defined(DEBUG) && DEBUG |
|
|
|
@ -932,14 +963,14 @@ void GPBSetUInt32IvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
if (self->messageStorage_ == NULL) return; |
|
|
|
|
#endif |
|
|
|
|
uint8_t *storage = (uint8_t *)self->messageStorage_; |
|
|
|
|
uint32_t *typePtr = (uint32_t *)&storage[field->description_->offset]; |
|
|
|
|
uint32_t *typePtr = (uint32_t *)&storage[fieldDesc->offset]; |
|
|
|
|
*typePtr = value; |
|
|
|
|
// proto2: any value counts as having been set; proto3, it |
|
|
|
|
// has to be a non zero value or be in a oneof. |
|
|
|
|
BOOL hasValue = ((syntax == GPBFileSyntaxProto2) |
|
|
|
|
|| (value != (uint32_t)0) |
|
|
|
|
|| (field->containingOneof_ != NULL)); |
|
|
|
|
GPBSetHasIvarField(self, field, hasValue); |
|
|
|
|
GPBSetHasIvar(self, fieldDesc->hasIndex, fieldDesc->number, hasValue); |
|
|
|
|
GPBBecomeVisibleToAutocreator(self); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -951,6 +982,9 @@ void GPBSetUInt32IvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
int64_t GPBGetMessageInt64Field(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field) { |
|
|
|
|
#if defined(DEBUG) && DEBUG |
|
|
|
|
NSCAssert([[self descriptor] fieldWithNumber:field.number] == field, |
|
|
|
|
@"FieldDescriptor %@ doesn't appear to be for %@ messages.", |
|
|
|
|
field.name, [self class]); |
|
|
|
|
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field), |
|
|
|
|
GPBDataTypeInt64), |
|
|
|
|
@"Attempting to get value of int64_t from field %@ " |
|
|
|
@ -972,15 +1006,10 @@ void GPBSetMessageInt64Field(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, |
|
|
|
|
int64_t value) { |
|
|
|
|
if (self == nil || field == nil) return; |
|
|
|
|
GPBFileSyntax syntax = [self descriptor].file.syntax; |
|
|
|
|
GPBSetInt64IvarWithFieldInternal(self, field, value, syntax); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void GPBSetInt64IvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, |
|
|
|
|
int64_t value, |
|
|
|
|
GPBFileSyntax syntax) { |
|
|
|
|
#if defined(DEBUG) && DEBUG |
|
|
|
|
NSCAssert([[self descriptor] fieldWithNumber:field.number] == field, |
|
|
|
|
@"FieldDescriptor %@ doesn't appear to be for %@ messages.", |
|
|
|
|
field.name, [self class]); |
|
|
|
|
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field), |
|
|
|
|
GPBDataTypeInt64), |
|
|
|
|
@"Attempting to set field %@ of %@ which is of type %@ with " |
|
|
|
@ -988,9 +1017,17 @@ void GPBSetInt64IvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
[self class], field.name, |
|
|
|
|
TypeToString(GPBGetFieldDataType(field))); |
|
|
|
|
#endif |
|
|
|
|
GPBFileSyntax syntax = [self descriptor].file.syntax; |
|
|
|
|
GPBSetInt64IvarWithFieldInternal(self, field, value, syntax); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void GPBSetInt64IvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, |
|
|
|
|
int64_t value, |
|
|
|
|
GPBFileSyntax syntax) { |
|
|
|
|
GPBOneofDescriptor *oneof = field->containingOneof_; |
|
|
|
|
GPBMessageFieldDescription *fieldDesc = field->description_; |
|
|
|
|
if (oneof) { |
|
|
|
|
GPBMessageFieldDescription *fieldDesc = field->description_; |
|
|
|
|
GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); |
|
|
|
|
} |
|
|
|
|
#if defined(DEBUG) && DEBUG |
|
|
|
@ -1002,14 +1039,14 @@ void GPBSetInt64IvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
if (self->messageStorage_ == NULL) return; |
|
|
|
|
#endif |
|
|
|
|
uint8_t *storage = (uint8_t *)self->messageStorage_; |
|
|
|
|
int64_t *typePtr = (int64_t *)&storage[field->description_->offset]; |
|
|
|
|
int64_t *typePtr = (int64_t *)&storage[fieldDesc->offset]; |
|
|
|
|
*typePtr = value; |
|
|
|
|
// proto2: any value counts as having been set; proto3, it |
|
|
|
|
// has to be a non zero value or be in a oneof. |
|
|
|
|
BOOL hasValue = ((syntax == GPBFileSyntaxProto2) |
|
|
|
|
|| (value != (int64_t)0) |
|
|
|
|
|| (field->containingOneof_ != NULL)); |
|
|
|
|
GPBSetHasIvarField(self, field, hasValue); |
|
|
|
|
GPBSetHasIvar(self, fieldDesc->hasIndex, fieldDesc->number, hasValue); |
|
|
|
|
GPBBecomeVisibleToAutocreator(self); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1021,6 +1058,9 @@ void GPBSetInt64IvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
uint64_t GPBGetMessageUInt64Field(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field) { |
|
|
|
|
#if defined(DEBUG) && DEBUG |
|
|
|
|
NSCAssert([[self descriptor] fieldWithNumber:field.number] == field, |
|
|
|
|
@"FieldDescriptor %@ doesn't appear to be for %@ messages.", |
|
|
|
|
field.name, [self class]); |
|
|
|
|
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field), |
|
|
|
|
GPBDataTypeUInt64), |
|
|
|
|
@"Attempting to get value of uint64_t from field %@ " |
|
|
|
@ -1042,15 +1082,10 @@ void GPBSetMessageUInt64Field(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, |
|
|
|
|
uint64_t value) { |
|
|
|
|
if (self == nil || field == nil) return; |
|
|
|
|
GPBFileSyntax syntax = [self descriptor].file.syntax; |
|
|
|
|
GPBSetUInt64IvarWithFieldInternal(self, field, value, syntax); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void GPBSetUInt64IvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, |
|
|
|
|
uint64_t value, |
|
|
|
|
GPBFileSyntax syntax) { |
|
|
|
|
#if defined(DEBUG) && DEBUG |
|
|
|
|
NSCAssert([[self descriptor] fieldWithNumber:field.number] == field, |
|
|
|
|
@"FieldDescriptor %@ doesn't appear to be for %@ messages.", |
|
|
|
|
field.name, [self class]); |
|
|
|
|
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field), |
|
|
|
|
GPBDataTypeUInt64), |
|
|
|
|
@"Attempting to set field %@ of %@ which is of type %@ with " |
|
|
|
@ -1058,9 +1093,17 @@ void GPBSetUInt64IvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
[self class], field.name, |
|
|
|
|
TypeToString(GPBGetFieldDataType(field))); |
|
|
|
|
#endif |
|
|
|
|
GPBFileSyntax syntax = [self descriptor].file.syntax; |
|
|
|
|
GPBSetUInt64IvarWithFieldInternal(self, field, value, syntax); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void GPBSetUInt64IvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, |
|
|
|
|
uint64_t value, |
|
|
|
|
GPBFileSyntax syntax) { |
|
|
|
|
GPBOneofDescriptor *oneof = field->containingOneof_; |
|
|
|
|
GPBMessageFieldDescription *fieldDesc = field->description_; |
|
|
|
|
if (oneof) { |
|
|
|
|
GPBMessageFieldDescription *fieldDesc = field->description_; |
|
|
|
|
GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); |
|
|
|
|
} |
|
|
|
|
#if defined(DEBUG) && DEBUG |
|
|
|
@ -1072,14 +1115,14 @@ void GPBSetUInt64IvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
if (self->messageStorage_ == NULL) return; |
|
|
|
|
#endif |
|
|
|
|
uint8_t *storage = (uint8_t *)self->messageStorage_; |
|
|
|
|
uint64_t *typePtr = (uint64_t *)&storage[field->description_->offset]; |
|
|
|
|
uint64_t *typePtr = (uint64_t *)&storage[fieldDesc->offset]; |
|
|
|
|
*typePtr = value; |
|
|
|
|
// proto2: any value counts as having been set; proto3, it |
|
|
|
|
// has to be a non zero value or be in a oneof. |
|
|
|
|
BOOL hasValue = ((syntax == GPBFileSyntaxProto2) |
|
|
|
|
|| (value != (uint64_t)0) |
|
|
|
|
|| (field->containingOneof_ != NULL)); |
|
|
|
|
GPBSetHasIvarField(self, field, hasValue); |
|
|
|
|
GPBSetHasIvar(self, fieldDesc->hasIndex, fieldDesc->number, hasValue); |
|
|
|
|
GPBBecomeVisibleToAutocreator(self); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1091,6 +1134,9 @@ void GPBSetUInt64IvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
float GPBGetMessageFloatField(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field) { |
|
|
|
|
#if defined(DEBUG) && DEBUG |
|
|
|
|
NSCAssert([[self descriptor] fieldWithNumber:field.number] == field, |
|
|
|
|
@"FieldDescriptor %@ doesn't appear to be for %@ messages.", |
|
|
|
|
field.name, [self class]); |
|
|
|
|
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field), |
|
|
|
|
GPBDataTypeFloat), |
|
|
|
|
@"Attempting to get value of float from field %@ " |
|
|
|
@ -1112,15 +1158,10 @@ void GPBSetMessageFloatField(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, |
|
|
|
|
float value) { |
|
|
|
|
if (self == nil || field == nil) return; |
|
|
|
|
GPBFileSyntax syntax = [self descriptor].file.syntax; |
|
|
|
|
GPBSetFloatIvarWithFieldInternal(self, field, value, syntax); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void GPBSetFloatIvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, |
|
|
|
|
float value, |
|
|
|
|
GPBFileSyntax syntax) { |
|
|
|
|
#if defined(DEBUG) && DEBUG |
|
|
|
|
NSCAssert([[self descriptor] fieldWithNumber:field.number] == field, |
|
|
|
|
@"FieldDescriptor %@ doesn't appear to be for %@ messages.", |
|
|
|
|
field.name, [self class]); |
|
|
|
|
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field), |
|
|
|
|
GPBDataTypeFloat), |
|
|
|
|
@"Attempting to set field %@ of %@ which is of type %@ with " |
|
|
|
@ -1128,9 +1169,17 @@ void GPBSetFloatIvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
[self class], field.name, |
|
|
|
|
TypeToString(GPBGetFieldDataType(field))); |
|
|
|
|
#endif |
|
|
|
|
GPBFileSyntax syntax = [self descriptor].file.syntax; |
|
|
|
|
GPBSetFloatIvarWithFieldInternal(self, field, value, syntax); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void GPBSetFloatIvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, |
|
|
|
|
float value, |
|
|
|
|
GPBFileSyntax syntax) { |
|
|
|
|
GPBOneofDescriptor *oneof = field->containingOneof_; |
|
|
|
|
GPBMessageFieldDescription *fieldDesc = field->description_; |
|
|
|
|
if (oneof) { |
|
|
|
|
GPBMessageFieldDescription *fieldDesc = field->description_; |
|
|
|
|
GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); |
|
|
|
|
} |
|
|
|
|
#if defined(DEBUG) && DEBUG |
|
|
|
@ -1142,14 +1191,14 @@ void GPBSetFloatIvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
if (self->messageStorage_ == NULL) return; |
|
|
|
|
#endif |
|
|
|
|
uint8_t *storage = (uint8_t *)self->messageStorage_; |
|
|
|
|
float *typePtr = (float *)&storage[field->description_->offset]; |
|
|
|
|
float *typePtr = (float *)&storage[fieldDesc->offset]; |
|
|
|
|
*typePtr = value; |
|
|
|
|
// proto2: any value counts as having been set; proto3, it |
|
|
|
|
// has to be a non zero value or be in a oneof. |
|
|
|
|
BOOL hasValue = ((syntax == GPBFileSyntaxProto2) |
|
|
|
|
|| (value != (float)0) |
|
|
|
|
|| (field->containingOneof_ != NULL)); |
|
|
|
|
GPBSetHasIvarField(self, field, hasValue); |
|
|
|
|
GPBSetHasIvar(self, fieldDesc->hasIndex, fieldDesc->number, hasValue); |
|
|
|
|
GPBBecomeVisibleToAutocreator(self); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1161,6 +1210,9 @@ void GPBSetFloatIvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
double GPBGetMessageDoubleField(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field) { |
|
|
|
|
#if defined(DEBUG) && DEBUG |
|
|
|
|
NSCAssert([[self descriptor] fieldWithNumber:field.number] == field, |
|
|
|
|
@"FieldDescriptor %@ doesn't appear to be for %@ messages.", |
|
|
|
|
field.name, [self class]); |
|
|
|
|
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field), |
|
|
|
|
GPBDataTypeDouble), |
|
|
|
|
@"Attempting to get value of double from field %@ " |
|
|
|
@ -1182,15 +1234,10 @@ void GPBSetMessageDoubleField(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, |
|
|
|
|
double value) { |
|
|
|
|
if (self == nil || field == nil) return; |
|
|
|
|
GPBFileSyntax syntax = [self descriptor].file.syntax; |
|
|
|
|
GPBSetDoubleIvarWithFieldInternal(self, field, value, syntax); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void GPBSetDoubleIvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, |
|
|
|
|
double value, |
|
|
|
|
GPBFileSyntax syntax) { |
|
|
|
|
#if defined(DEBUG) && DEBUG |
|
|
|
|
NSCAssert([[self descriptor] fieldWithNumber:field.number] == field, |
|
|
|
|
@"FieldDescriptor %@ doesn't appear to be for %@ messages.", |
|
|
|
|
field.name, [self class]); |
|
|
|
|
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field), |
|
|
|
|
GPBDataTypeDouble), |
|
|
|
|
@"Attempting to set field %@ of %@ which is of type %@ with " |
|
|
|
@ -1198,9 +1245,17 @@ void GPBSetDoubleIvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
[self class], field.name, |
|
|
|
|
TypeToString(GPBGetFieldDataType(field))); |
|
|
|
|
#endif |
|
|
|
|
GPBFileSyntax syntax = [self descriptor].file.syntax; |
|
|
|
|
GPBSetDoubleIvarWithFieldInternal(self, field, value, syntax); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void GPBSetDoubleIvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, |
|
|
|
|
double value, |
|
|
|
|
GPBFileSyntax syntax) { |
|
|
|
|
GPBOneofDescriptor *oneof = field->containingOneof_; |
|
|
|
|
GPBMessageFieldDescription *fieldDesc = field->description_; |
|
|
|
|
if (oneof) { |
|
|
|
|
GPBMessageFieldDescription *fieldDesc = field->description_; |
|
|
|
|
GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number); |
|
|
|
|
} |
|
|
|
|
#if defined(DEBUG) && DEBUG |
|
|
|
@ -1212,14 +1267,14 @@ void GPBSetDoubleIvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
if (self->messageStorage_ == NULL) return; |
|
|
|
|
#endif |
|
|
|
|
uint8_t *storage = (uint8_t *)self->messageStorage_; |
|
|
|
|
double *typePtr = (double *)&storage[field->description_->offset]; |
|
|
|
|
double *typePtr = (double *)&storage[fieldDesc->offset]; |
|
|
|
|
*typePtr = value; |
|
|
|
|
// proto2: any value counts as having been set; proto3, it |
|
|
|
|
// has to be a non zero value or be in a oneof. |
|
|
|
|
BOOL hasValue = ((syntax == GPBFileSyntaxProto2) |
|
|
|
|
|| (value != (double)0) |
|
|
|
|
|| (field->containingOneof_ != NULL)); |
|
|
|
|
GPBSetHasIvarField(self, field, hasValue); |
|
|
|
|
GPBSetHasIvar(self, fieldDesc->hasIndex, fieldDesc->number, hasValue); |
|
|
|
|
GPBBecomeVisibleToAutocreator(self); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|