| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #define GPBNSStringify(S) @#S | 43 #define GPBNSStringify(S) @#S |
| 44 #define GPBNSStringifySymbol(S) GPBNSStringify(S) | 44 #define GPBNSStringifySymbol(S) GPBNSStringify(S) |
| 45 | 45 |
| 46 // Constant to internally mark when there is no has bit. | 46 // Constant to internally mark when there is no has bit. |
| 47 #define GPBNoHasBit INT32_MAX | 47 #define GPBNoHasBit INT32_MAX |
| 48 | 48 |
| 49 CF_EXTERN_C_BEGIN | 49 CF_EXTERN_C_BEGIN |
| 50 | 50 |
| 51 // These two are used to inject a runtime check for version mismatch into the | 51 // These two are used to inject a runtime check for version mismatch into the |
| 52 // generated sources to make sure they are linked with a supporting runtime. | 52 // generated sources to make sure they are linked with a supporting runtime. |
| 53 void GPBCheckRuntimeVersionSupport(int32_t objcRuntimeVersion); | |
| 54 GPB_INLINE void GPB_DEBUG_CHECK_RUNTIME_VERSIONS() { | |
| 55 // NOTE: By being inline here, this captures the value from the library's | |
| 56 // headers at the time the generated code was compiled. | |
| 57 #if defined(DEBUG) && DEBUG | |
| 58 GPBCheckRuntimeVersionSupport(GOOGLE_PROTOBUF_OBJC_VERSION); | |
| 59 #endif | |
| 60 } | |
| 61 | |
| 62 // Legacy version of the checks, remove when GOOGLE_PROTOBUF_OBJC_GEN_VERSION | |
| 63 // goes away (see more info in GPBBootstrap.h). | |
| 64 void GPBCheckRuntimeVersionInternal(int32_t version); | 53 void GPBCheckRuntimeVersionInternal(int32_t version); |
| 65 GPB_INLINE void GPBDebugCheckRuntimeVersion() { | 54 GPB_INLINE void GPBDebugCheckRuntimeVersion() { |
| 66 #if defined(DEBUG) && DEBUG | 55 #if DEBUG |
| 67 GPBCheckRuntimeVersionInternal(GOOGLE_PROTOBUF_OBJC_GEN_VERSION); | 56 GPBCheckRuntimeVersionInternal(GOOGLE_PROTOBUF_OBJC_GEN_VERSION); |
| 68 #endif | 57 #endif |
| 69 } | 58 } |
| 70 | 59 |
| 71 // Conversion functions for de/serializing floating point types. | 60 // Conversion functions for de/serializing floating point types. |
| 72 | 61 |
| 73 GPB_INLINE int64_t GPBConvertDoubleToInt64(double v) { | 62 GPB_INLINE int64_t GPBConvertDoubleToInt64(double v) { |
| 74 union { double f; int64_t i; } u; | 63 union { double f; int64_t i; } u; |
| 75 u.f = v; | 64 u.f = v; |
| 76 return u.i; | 65 return u.i; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 100 | 89 |
| 101 GPB_INLINE int64_t GPBLogicalRightShift64(int64_t value, int32_t spaces) { | 90 GPB_INLINE int64_t GPBLogicalRightShift64(int64_t value, int32_t spaces) { |
| 102 return (int64_t)((uint64_t)(value) >> spaces); | 91 return (int64_t)((uint64_t)(value) >> spaces); |
| 103 } | 92 } |
| 104 | 93 |
| 105 // Decode a ZigZag-encoded 32-bit value. ZigZag encodes signed integers | 94 // Decode a ZigZag-encoded 32-bit value. ZigZag encodes signed integers |
| 106 // into values that can be efficiently encoded with varint. (Otherwise, | 95 // into values that can be efficiently encoded with varint. (Otherwise, |
| 107 // negative values must be sign-extended to 64 bits to be varint encoded, | 96 // negative values must be sign-extended to 64 bits to be varint encoded, |
| 108 // thus always taking 10 bytes on the wire.) | 97 // thus always taking 10 bytes on the wire.) |
| 109 GPB_INLINE int32_t GPBDecodeZigZag32(uint32_t n) { | 98 GPB_INLINE int32_t GPBDecodeZigZag32(uint32_t n) { |
| 110 return (int32_t)(GPBLogicalRightShift32((int32_t)n, 1) ^ -((int32_t)(n) & 1)); | 99 return GPBLogicalRightShift32(n, 1) ^ -(n & 1); |
| 111 } | 100 } |
| 112 | 101 |
| 113 // Decode a ZigZag-encoded 64-bit value. ZigZag encodes signed integers | 102 // Decode a ZigZag-encoded 64-bit value. ZigZag encodes signed integers |
| 114 // into values that can be efficiently encoded with varint. (Otherwise, | 103 // into values that can be efficiently encoded with varint. (Otherwise, |
| 115 // negative values must be sign-extended to 64 bits to be varint encoded, | 104 // negative values must be sign-extended to 64 bits to be varint encoded, |
| 116 // thus always taking 10 bytes on the wire.) | 105 // thus always taking 10 bytes on the wire.) |
| 117 GPB_INLINE int64_t GPBDecodeZigZag64(uint64_t n) { | 106 GPB_INLINE int64_t GPBDecodeZigZag64(uint64_t n) { |
| 118 return (int64_t)(GPBLogicalRightShift64((int64_t)n, 1) ^ -((int64_t)(n) & 1)); | 107 return GPBLogicalRightShift64(n, 1) ^ -(n & 1); |
| 119 } | 108 } |
| 120 | 109 |
| 121 // Encode a ZigZag-encoded 32-bit value. ZigZag encodes signed integers | 110 // Encode a ZigZag-encoded 32-bit value. ZigZag encodes signed integers |
| 122 // into values that can be efficiently encoded with varint. (Otherwise, | 111 // into values that can be efficiently encoded with varint. (Otherwise, |
| 123 // negative values must be sign-extended to 64 bits to be varint encoded, | 112 // negative values must be sign-extended to 64 bits to be varint encoded, |
| 124 // thus always taking 10 bytes on the wire.) | 113 // thus always taking 10 bytes on the wire.) |
| 125 GPB_INLINE uint32_t GPBEncodeZigZag32(int32_t n) { | 114 GPB_INLINE uint32_t GPBEncodeZigZag32(int32_t n) { |
| 126 // Note: the right-shift must be arithmetic | 115 // Note: the right-shift must be arithmetic |
| 127 return (uint32_t)((n << 1) ^ (n >> 31)); | 116 return (n << 1) ^ (n >> 31); |
| 128 } | 117 } |
| 129 | 118 |
| 130 // Encode a ZigZag-encoded 64-bit value. ZigZag encodes signed integers | 119 // Encode a ZigZag-encoded 64-bit value. ZigZag encodes signed integers |
| 131 // into values that can be efficiently encoded with varint. (Otherwise, | 120 // into values that can be efficiently encoded with varint. (Otherwise, |
| 132 // negative values must be sign-extended to 64 bits to be varint encoded, | 121 // negative values must be sign-extended to 64 bits to be varint encoded, |
| 133 // thus always taking 10 bytes on the wire.) | 122 // thus always taking 10 bytes on the wire.) |
| 134 GPB_INLINE uint64_t GPBEncodeZigZag64(int64_t n) { | 123 GPB_INLINE uint64_t GPBEncodeZigZag64(int64_t n) { |
| 135 // Note: the right-shift must be arithmetic | 124 // Note: the right-shift must be arithmetic |
| 136 return (uint64_t)((n << 1) ^ (n >> 63)); | 125 return (n << 1) ^ (n >> 63); |
| 137 } | 126 } |
| 138 | 127 |
| 139 #pragma clang diagnostic push | |
| 140 #pragma clang diagnostic ignored "-Wswitch-enum" | |
| 141 #pragma clang diagnostic ignored "-Wdirect-ivar-access" | |
| 142 | |
| 143 GPB_INLINE BOOL GPBDataTypeIsObject(GPBDataType type) { | 128 GPB_INLINE BOOL GPBDataTypeIsObject(GPBDataType type) { |
| 144 switch (type) { | 129 switch (type) { |
| 145 case GPBDataTypeBytes: | 130 case GPBDataTypeBytes: |
| 146 case GPBDataTypeString: | 131 case GPBDataTypeString: |
| 147 case GPBDataTypeMessage: | 132 case GPBDataTypeMessage: |
| 148 case GPBDataTypeGroup: | 133 case GPBDataTypeGroup: |
| 149 return YES; | 134 return YES; |
| 150 default: | 135 default: |
| 151 return NO; | 136 return NO; |
| 152 } | 137 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 } | 180 } |
| 196 GPB_INLINE void GPBSetHasIvarField(GPBMessage *self, GPBFieldDescriptor *field, | 181 GPB_INLINE void GPBSetHasIvarField(GPBMessage *self, GPBFieldDescriptor *field, |
| 197 BOOL value) { | 182 BOOL value) { |
| 198 GPBMessageFieldDescription *fieldDesc = field->description_; | 183 GPBMessageFieldDescription *fieldDesc = field->description_; |
| 199 GPBSetHasIvar(self, fieldDesc->hasIndex, fieldDesc->number, value); | 184 GPBSetHasIvar(self, fieldDesc->hasIndex, fieldDesc->number, value); |
| 200 } | 185 } |
| 201 | 186 |
| 202 void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof, | 187 void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof, |
| 203 int32_t oneofHasIndex, uint32_t fieldNumberNotToClear); | 188 int32_t oneofHasIndex, uint32_t fieldNumberNotToClear); |
| 204 | 189 |
| 205 #pragma clang diagnostic pop | |
| 206 | |
| 207 //%PDDM-DEFINE GPB_IVAR_SET_DECL(NAME, TYPE) | 190 //%PDDM-DEFINE GPB_IVAR_SET_DECL(NAME, TYPE) |
| 208 //%void GPBSet##NAME##IvarWithFieldInternal(GPBMessage *self, | 191 //%void GPBSet##NAME##IvarWithFieldInternal(GPBMessage *self, |
| 209 //% NAME$S GPBFieldDescriptor *field, | 192 //% NAME$S GPBFieldDescriptor *field, |
| 210 //% NAME$S TYPE value, | 193 //% NAME$S TYPE value, |
| 211 //% NAME$S GPBFileSyntax syntax); | 194 //% NAME$S GPBFileSyntax syntax); |
| 212 //%PDDM-EXPAND GPB_IVAR_SET_DECL(Bool, BOOL) | 195 //%PDDM-EXPAND GPB_IVAR_SET_DECL(Bool, BOOL) |
| 213 // This block of code is generated, do not edit it directly. | 196 // This block of code is generated, do not edit it directly. |
| 214 | 197 |
| 215 void GPBSetBoolIvarWithFieldInternal(GPBMessage *self, | 198 void GPBSetBoolIvarWithFieldInternal(GPBMessage *self, |
| 216 GPBFieldDescriptor *field, | 199 GPBFieldDescriptor *field, |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 | 322 |
| 340 #undef GPB_MESSAGE_SIGNATURE_ENTRY | 323 #undef GPB_MESSAGE_SIGNATURE_ENTRY |
| 341 | 324 |
| 342 - (id)getArray; | 325 - (id)getArray; |
| 343 - (NSUInteger)getArrayCount; | 326 - (NSUInteger)getArrayCount; |
| 344 - (void)setArray:(NSArray *)array; | 327 - (void)setArray:(NSArray *)array; |
| 345 + (id)getClassValue; | 328 + (id)getClassValue; |
| 346 @end | 329 @end |
| 347 | 330 |
| 348 CF_EXTERN_C_END | 331 CF_EXTERN_C_END |
| OLD | NEW |