|
|
|
@ -40,17 +40,15 @@ |
|
|
|
|
#define GPBStringify(S) #S |
|
|
|
|
#define GPBStringifySymbol(S) GPBStringify(S) |
|
|
|
|
|
|
|
|
|
#define GPBNSStringify(S) @#S |
|
|
|
|
#define GPBNSStringify(S) @ #S |
|
|
|
|
#define GPBNSStringifySymbol(S) GPBNSStringify(S) |
|
|
|
|
|
|
|
|
|
// Macros for generating a Class from a class name. These are used in
|
|
|
|
|
// the generated GPB descriptor classes wherever an Objective C class
|
|
|
|
|
// reference is needed for a generated class.
|
|
|
|
|
#define GPBObjCClassSymbol(name) OBJC_CLASS_$_##name |
|
|
|
|
#define GPBObjCClass(name) \ |
|
|
|
|
((__bridge Class)&(GPBObjCClassSymbol(name))) |
|
|
|
|
#define GPBObjCClassDeclaration(name) \ |
|
|
|
|
extern const GPBObjcClass_t GPBObjCClassSymbol(name) |
|
|
|
|
#define GPBObjCClass(name) ((__bridge Class) & (GPBObjCClassSymbol(name))) |
|
|
|
|
#define GPBObjCClassDeclaration(name) extern const GPBObjcClass_t GPBObjCClassSymbol(name) |
|
|
|
|
|
|
|
|
|
// Constant to internally mark when there is no has bit.
|
|
|
|
|
#define GPBNoHasBit INT32_MAX |
|
|
|
@ -120,7 +118,7 @@ GPB_INLINE int64_t GPBLogicalRightShift64(int64_t value, int32_t spaces) { |
|
|
|
|
// negative values must be sign-extended to 64 bits to be varint encoded,
|
|
|
|
|
// thus always taking 10 bytes on the wire.)
|
|
|
|
|
GPB_INLINE int32_t GPBDecodeZigZag32(uint32_t n) { |
|
|
|
|
return (int32_t)(GPBLogicalRightShift32((int32_t)n, 1) ^ -((int32_t)(n) & 1)); |
|
|
|
|
return (int32_t)(GPBLogicalRightShift32((int32_t)n, 1) ^ -((int32_t)(n)&1)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Decode a ZigZag-encoded 64-bit value. ZigZag encodes signed integers
|
|
|
|
@ -128,7 +126,7 @@ GPB_INLINE int32_t GPBDecodeZigZag32(uint32_t n) { |
|
|
|
|
// negative values must be sign-extended to 64 bits to be varint encoded,
|
|
|
|
|
// thus always taking 10 bytes on the wire.)
|
|
|
|
|
GPB_INLINE int64_t GPBDecodeZigZag64(uint64_t n) { |
|
|
|
|
return (int64_t)(GPBLogicalRightShift64((int64_t)n, 1) ^ -((int64_t)(n) & 1)); |
|
|
|
|
return (int64_t)(GPBLogicalRightShift64((int64_t)n, 1) ^ -((int64_t)(n)&1)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Encode a ZigZag-encoded 32-bit value. ZigZag encodes signed integers
|
|
|
|
@ -197,12 +195,10 @@ GPB_INLINE BOOL GPBFieldStoresObject(GPBFieldDescriptor *field) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
BOOL GPBGetHasIvar(GPBMessage *self, int32_t index, uint32_t fieldNumber); |
|
|
|
|
void GPBSetHasIvar(GPBMessage *self, int32_t idx, uint32_t fieldNumber, |
|
|
|
|
BOOL value); |
|
|
|
|
void GPBSetHasIvar(GPBMessage *self, int32_t idx, uint32_t fieldNumber, BOOL value); |
|
|
|
|
uint32_t GPBGetHasOneof(GPBMessage *self, int32_t index); |
|
|
|
|
|
|
|
|
|
GPB_INLINE BOOL |
|
|
|
|
GPBGetHasIvarField(GPBMessage *self, GPBFieldDescriptor *field) { |
|
|
|
|
GPB_INLINE BOOL GPBGetHasIvarField(GPBMessage *self, GPBFieldDescriptor *field) { |
|
|
|
|
GPBMessageFieldDescription *fieldDesc = field->description_; |
|
|
|
|
return GPBGetHasIvar(self, fieldDesc->hasIndex, fieldDesc->number); |
|
|
|
|
} |
|
|
|
@ -262,28 +258,21 @@ void GPBSetDoubleIvarWithFieldPrivate(GPBMessage *self, |
|
|
|
|
|
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
|
|
void GPBSetEnumIvarWithFieldPrivate(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, |
|
|
|
|
int32_t value); |
|
|
|
|
void GPBSetEnumIvarWithFieldPrivate(GPBMessage *self, GPBFieldDescriptor *field, int32_t value); |
|
|
|
|
|
|
|
|
|
id GPBGetObjectIvarWithField(GPBMessage *self, GPBFieldDescriptor *field); |
|
|
|
|
|
|
|
|
|
void GPBSetObjectIvarWithFieldPrivate(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, id value); |
|
|
|
|
void GPBSetRetainedObjectIvarWithFieldPrivate(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, |
|
|
|
|
id __attribute__((ns_consumed)) |
|
|
|
|
value); |
|
|
|
|
void GPBSetObjectIvarWithFieldPrivate(GPBMessage *self, GPBFieldDescriptor *field, id value); |
|
|
|
|
void GPBSetRetainedObjectIvarWithFieldPrivate(GPBMessage *self, GPBFieldDescriptor *field, |
|
|
|
|
id __attribute__((ns_consumed)) value); |
|
|
|
|
|
|
|
|
|
// GPBGetObjectIvarWithField will automatically create the field (message) if
|
|
|
|
|
// it doesn't exist. GPBGetObjectIvarWithFieldNoAutocreate will return nil.
|
|
|
|
|
id GPBGetObjectIvarWithFieldNoAutocreate(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field); |
|
|
|
|
id GPBGetObjectIvarWithFieldNoAutocreate(GPBMessage *self, GPBFieldDescriptor *field); |
|
|
|
|
|
|
|
|
|
// Clears and releases the autocreated message ivar, if it's autocreated. If
|
|
|
|
|
// it's not set as autocreated, this method does nothing.
|
|
|
|
|
void GPBClearAutocreatedMessageIvarWithField(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field); |
|
|
|
|
void GPBClearAutocreatedMessageIvarWithField(GPBMessage *self, GPBFieldDescriptor *field); |
|
|
|
|
|
|
|
|
|
// Returns an Objective C encoding for |selector|. |instanceSel| should be
|
|
|
|
|
// YES if it's an instance selector (as opposed to a class selector).
|
|
|
|
@ -293,17 +282,13 @@ const char *GPBMessageEncodingForSelector(SEL selector, BOOL instanceSel); |
|
|
|
|
// Helper for text format name encoding.
|
|
|
|
|
// decodeData is the data describing the special decodes.
|
|
|
|
|
// key and inputString are the input that needs decoding.
|
|
|
|
|
NSString *GPBDecodeTextFormatName(const uint8_t *decodeData, int32_t key, |
|
|
|
|
NSString *inputString); |
|
|
|
|
|
|
|
|
|
NSString *GPBDecodeTextFormatName(const uint8_t *decodeData, int32_t key, NSString *inputString); |
|
|
|
|
|
|
|
|
|
// Shims from the older generated code into the runtime.
|
|
|
|
|
void GPBSetInt32IvarWithFieldInternal(GPBMessage *self, |
|
|
|
|
GPBFieldDescriptor *field, |
|
|
|
|
int32_t value, |
|
|
|
|
void GPBSetInt32IvarWithFieldInternal(GPBMessage *self, GPBFieldDescriptor *field, int32_t value, |
|
|
|
|
GPBFileSyntax syntax); |
|
|
|
|
void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof, |
|
|
|
|
int32_t oneofHasIndex, uint32_t fieldNumberNotToClear); |
|
|
|
|
void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof, int32_t oneofHasIndex, |
|
|
|
|
uint32_t fieldNumberNotToClear); |
|
|
|
|
|
|
|
|
|
// A series of selectors that are used solely to get @encoding values
|
|
|
|
|
// for them by the dynamic protobuf runtime code. See
|
|
|
|
|