diff options
Diffstat (limited to 'objectivec/GPBUtilities_PackagePrivate.h')
-rw-r--r-- | objectivec/GPBUtilities_PackagePrivate.h | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/objectivec/GPBUtilities_PackagePrivate.h b/objectivec/GPBUtilities_PackagePrivate.h index cac551f6..ed424ce3 100644 --- a/objectivec/GPBUtilities_PackagePrivate.h +++ b/objectivec/GPBUtilities_PackagePrivate.h @@ -50,9 +50,20 @@ CF_EXTERN_C_BEGIN // These two are used to inject a runtime check for version mismatch into the // generated sources to make sure they are linked with a supporting runtime. +void GPBCheckRuntimeVersionSupport(int32_t objcRuntimeVersion); +GPB_INLINE void GPB_DEBUG_CHECK_RUNTIME_VERSIONS() { + // NOTE: By being inline here, this captures the value from the library's + // headers at the time the generated code was compiled. +#if defined(DEBUG) && DEBUG + GPBCheckRuntimeVersionSupport(GOOGLE_PROTOBUF_OBJC_VERSION); +#endif +} + +// Legacy version of the checks, remove when GOOGLE_PROTOBUF_OBJC_GEN_VERSION +// goes away (see more info in GPBBootstrap.h). void GPBCheckRuntimeVersionInternal(int32_t version); GPB_INLINE void GPBDebugCheckRuntimeVersion() { -#if DEBUG +#if defined(DEBUG) && DEBUG GPBCheckRuntimeVersionInternal(GOOGLE_PROTOBUF_OBJC_GEN_VERSION); #endif } @@ -96,7 +107,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 GPBLogicalRightShift32(n, 1) ^ -(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 @@ -104,7 +115,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 GPBLogicalRightShift64(n, 1) ^ -(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 @@ -113,7 +124,7 @@ GPB_INLINE int64_t GPBDecodeZigZag64(uint64_t n) { // thus always taking 10 bytes on the wire.) GPB_INLINE uint32_t GPBEncodeZigZag32(int32_t n) { // Note: the right-shift must be arithmetic - return (n << 1) ^ (n >> 31); + return ((uint32_t)n << 1) ^ (uint32_t)(n >> 31); } // Encode a ZigZag-encoded 64-bit value. ZigZag encodes signed integers @@ -122,9 +133,13 @@ GPB_INLINE uint32_t GPBEncodeZigZag32(int32_t n) { // thus always taking 10 bytes on the wire.) GPB_INLINE uint64_t GPBEncodeZigZag64(int64_t n) { // Note: the right-shift must be arithmetic - return (n << 1) ^ (n >> 63); + return ((uint64_t)n << 1) ^ (uint64_t)(n >> 63); } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wswitch-enum" +#pragma clang diagnostic ignored "-Wdirect-ivar-access" + GPB_INLINE BOOL GPBDataTypeIsObject(GPBDataType type) { switch (type) { case GPBDataTypeBytes: @@ -185,7 +200,9 @@ GPB_INLINE void GPBSetHasIvarField(GPBMessage *self, GPBFieldDescriptor *field, } void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof, - uint32_t fieldNumberNotToClear); + int32_t oneofHasIndex, uint32_t fieldNumberNotToClear); + +#pragma clang diagnostic pop //%PDDM-DEFINE GPB_IVAR_SET_DECL(NAME, TYPE) //%void GPBSet##NAME##IvarWithFieldInternal(GPBMessage *self, @@ -292,7 +309,8 @@ NSString *GPBDecodeTextFormatName(const uint8_t *decodeData, int32_t key, // A series of selectors that are used solely to get @encoding values // for them by the dynamic protobuf runtime code. See -// GPBMessageEncodingForSelector for details. +// GPBMessageEncodingForSelector for details. GPBRootObject conforms to +// the protocol so that it is encoded in the Objective C runtime. @protocol GPBMessageSignatureProtocol @optional @@ -328,4 +346,6 @@ GPB_MESSAGE_SIGNATURE_ENTRY(int32_t, Enum) + (id)getClassValue; @end +BOOL GPBClassHasSel(Class aClass, SEL sel); + CF_EXTERN_C_END |