Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Unified Diff: third_party/protobuf/objectivec/GPBUtilities_PackagePrivate.h

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Make chrome settings proto generated file a component Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/protobuf/objectivec/GPBUtilities.m ('k') | third_party/protobuf/objectivec/GPBWellKnownTypes.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/protobuf/objectivec/GPBUtilities_PackagePrivate.h
diff --git a/third_party/protobuf/objectivec/GPBUtilities_PackagePrivate.h b/third_party/protobuf/objectivec/GPBUtilities_PackagePrivate.h
index a6b6c84d988064c5e8f1d90ab7240a75c1df63df..274351b71292a294415483021d7ecbd32f7ded6e 100644
--- a/third_party/protobuf/objectivec/GPBUtilities_PackagePrivate.h
+++ b/third_party/protobuf/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) ^ (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) ^ (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:
@@ -187,6 +202,8 @@ GPB_INLINE void GPBSetHasIvarField(GPBMessage *self, GPBFieldDescriptor *field,
void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof,
int32_t oneofHasIndex, uint32_t fieldNumberNotToClear);
+#pragma clang diagnostic pop
+
//%PDDM-DEFINE GPB_IVAR_SET_DECL(NAME, TYPE)
//%void GPBSet##NAME##IvarWithFieldInternal(GPBMessage *self,
//% NAME$S GPBFieldDescriptor *field,
« no previous file with comments | « third_party/protobuf/objectivec/GPBUtilities.m ('k') | third_party/protobuf/objectivec/GPBWellKnownTypes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698