Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1 | // Protocol Buffers - Google's data interchange format |
| 2 | // Copyright 2008 Google Inc. All rights reserved. |
| 3 | // https://developers.google.com/protocol-buffers/ |
| 4 | // |
| 5 | // Redistribution and use in source and binary forms, with or without |
| 6 | // modification, are permitted provided that the following conditions are |
| 7 | // met: |
| 8 | // |
| 9 | // * Redistributions of source code must retain the above copyright |
| 10 | // notice, this list of conditions and the following disclaimer. |
| 11 | // * Redistributions in binary form must reproduce the above |
| 12 | // copyright notice, this list of conditions and the following disclaimer |
| 13 | // in the documentation and/or other materials provided with the |
| 14 | // distribution. |
| 15 | // * Neither the name of Google Inc. nor the names of its |
| 16 | // contributors may be used to endorse or promote products derived from |
| 17 | // this software without specific prior written permission. |
| 18 | // |
| 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | |
| 31 | #import <Foundation/Foundation.h> |
| 32 | |
| 33 | #import "GPBUtilities.h" |
| 34 | |
| 35 | #import "GPBDescriptor_PackagePrivate.h" |
| 36 | |
| 37 | // Macros for stringifying library symbols. These are used in the generated |
Dave MacLachlan | aa1d7e7 | 2020-01-19 17:46:35 -0800 | [diff] [blame] | 38 | // GPB descriptor classes wherever a library symbol name is represented as a |
| 39 | // string. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 40 | #define GPBStringify(S) #S |
| 41 | #define GPBStringifySymbol(S) GPBStringify(S) |
| 42 | |
| 43 | #define GPBNSStringify(S) @#S |
| 44 | #define GPBNSStringifySymbol(S) GPBNSStringify(S) |
| 45 | |
Dave MacLachlan | aa1d7e7 | 2020-01-19 17:46:35 -0800 | [diff] [blame] | 46 | // Macros for generating a Class from a class name. These are used in |
| 47 | // the generated GPB descriptor classes wherever an Objective C class |
| 48 | // reference is needed for a generated class. |
| 49 | #define GPBObjCClassSymbol(name) OBJC_CLASS_$_##name |
| 50 | #define GPBObjCClass(name) \ |
| 51 | ((__bridge Class)&(GPBObjCClassSymbol(name))) |
| 52 | #define GPBObjCClassDeclaration(name) \ |
| 53 | extern const GPBObjcClass_t GPBObjCClassSymbol(name) |
| 54 | |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 55 | // Constant to internally mark when there is no has bit. |
| 56 | #define GPBNoHasBit INT32_MAX |
| 57 | |
| 58 | CF_EXTERN_C_BEGIN |
| 59 | |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 60 | // These two are used to inject a runtime check for version mismatch into the |
| 61 | // generated sources to make sure they are linked with a supporting runtime. |
Thomas Van Lenten | 1aa6500 | 2016-09-15 13:27:17 -0400 | [diff] [blame] | 62 | void GPBCheckRuntimeVersionSupport(int32_t objcRuntimeVersion); |
| 63 | GPB_INLINE void GPB_DEBUG_CHECK_RUNTIME_VERSIONS() { |
| 64 | // NOTE: By being inline here, this captures the value from the library's |
| 65 | // headers at the time the generated code was compiled. |
| 66 | #if defined(DEBUG) && DEBUG |
| 67 | GPBCheckRuntimeVersionSupport(GOOGLE_PROTOBUF_OBJC_VERSION); |
| 68 | #endif |
| 69 | } |
| 70 | |
| 71 | // Legacy version of the checks, remove when GOOGLE_PROTOBUF_OBJC_GEN_VERSION |
| 72 | // goes away (see more info in GPBBootstrap.h). |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 73 | void GPBCheckRuntimeVersionInternal(int32_t version); |
| 74 | GPB_INLINE void GPBDebugCheckRuntimeVersion() { |
Thomas Van Lenten | c8a440d | 2016-05-25 13:46:00 -0400 | [diff] [blame] | 75 | #if defined(DEBUG) && DEBUG |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 76 | GPBCheckRuntimeVersionInternal(GOOGLE_PROTOBUF_OBJC_GEN_VERSION); |
| 77 | #endif |
| 78 | } |
| 79 | |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 80 | // Conversion functions for de/serializing floating point types. |
| 81 | |
| 82 | GPB_INLINE int64_t GPBConvertDoubleToInt64(double v) { |
Thomas Van Lenten | 5846439 | 2019-09-20 10:52:34 -0400 | [diff] [blame] | 83 | GPBInternalCompileAssert(sizeof(double) == sizeof(int64_t), double_not_64_bits); |
| 84 | int64_t result; |
| 85 | memcpy(&result, &v, sizeof(result)); |
| 86 | return result; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | GPB_INLINE int32_t GPBConvertFloatToInt32(float v) { |
Thomas Van Lenten | 5846439 | 2019-09-20 10:52:34 -0400 | [diff] [blame] | 90 | GPBInternalCompileAssert(sizeof(float) == sizeof(int32_t), float_not_32_bits); |
| 91 | int32_t result; |
| 92 | memcpy(&result, &v, sizeof(result)); |
| 93 | return result; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | GPB_INLINE double GPBConvertInt64ToDouble(int64_t v) { |
Thomas Van Lenten | 5846439 | 2019-09-20 10:52:34 -0400 | [diff] [blame] | 97 | GPBInternalCompileAssert(sizeof(double) == sizeof(int64_t), double_not_64_bits); |
| 98 | double result; |
| 99 | memcpy(&result, &v, sizeof(result)); |
| 100 | return result; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | GPB_INLINE float GPBConvertInt32ToFloat(int32_t v) { |
Thomas Van Lenten | 5846439 | 2019-09-20 10:52:34 -0400 | [diff] [blame] | 104 | GPBInternalCompileAssert(sizeof(float) == sizeof(int32_t), float_not_32_bits); |
| 105 | float result; |
| 106 | memcpy(&result, &v, sizeof(result)); |
| 107 | return result; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | GPB_INLINE int32_t GPBLogicalRightShift32(int32_t value, int32_t spaces) { |
| 111 | return (int32_t)((uint32_t)(value) >> spaces); |
| 112 | } |
| 113 | |
| 114 | GPB_INLINE int64_t GPBLogicalRightShift64(int64_t value, int32_t spaces) { |
| 115 | return (int64_t)((uint64_t)(value) >> spaces); |
| 116 | } |
| 117 | |
| 118 | // Decode a ZigZag-encoded 32-bit value. ZigZag encodes signed integers |
| 119 | // into values that can be efficiently encoded with varint. (Otherwise, |
| 120 | // negative values must be sign-extended to 64 bits to be varint encoded, |
| 121 | // thus always taking 10 bytes on the wire.) |
| 122 | GPB_INLINE int32_t GPBDecodeZigZag32(uint32_t n) { |
Sergio Campama | e505098 | 2016-08-16 08:56:50 -0700 | [diff] [blame] | 123 | return (int32_t)(GPBLogicalRightShift32((int32_t)n, 1) ^ -((int32_t)(n) & 1)); |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | // Decode a ZigZag-encoded 64-bit value. ZigZag encodes signed integers |
| 127 | // into values that can be efficiently encoded with varint. (Otherwise, |
| 128 | // negative values must be sign-extended to 64 bits to be varint encoded, |
| 129 | // thus always taking 10 bytes on the wire.) |
| 130 | GPB_INLINE int64_t GPBDecodeZigZag64(uint64_t n) { |
Sergio Campama | e505098 | 2016-08-16 08:56:50 -0700 | [diff] [blame] | 131 | return (int64_t)(GPBLogicalRightShift64((int64_t)n, 1) ^ -((int64_t)(n) & 1)); |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | // Encode a ZigZag-encoded 32-bit value. ZigZag encodes signed integers |
| 135 | // into values that can be efficiently encoded with varint. (Otherwise, |
| 136 | // negative values must be sign-extended to 64 bits to be varint encoded, |
| 137 | // thus always taking 10 bytes on the wire.) |
| 138 | GPB_INLINE uint32_t GPBEncodeZigZag32(int32_t n) { |
| 139 | // Note: the right-shift must be arithmetic |
Thomas Van Lenten | 953adb1 | 2018-01-31 11:59:57 -0500 | [diff] [blame] | 140 | return ((uint32_t)n << 1) ^ (uint32_t)(n >> 31); |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | // Encode a ZigZag-encoded 64-bit value. ZigZag encodes signed integers |
| 144 | // into values that can be efficiently encoded with varint. (Otherwise, |
| 145 | // negative values must be sign-extended to 64 bits to be varint encoded, |
| 146 | // thus always taking 10 bytes on the wire.) |
| 147 | GPB_INLINE uint64_t GPBEncodeZigZag64(int64_t n) { |
| 148 | // Note: the right-shift must be arithmetic |
Thomas Van Lenten | 953adb1 | 2018-01-31 11:59:57 -0500 | [diff] [blame] | 149 | return ((uint64_t)n << 1) ^ (uint64_t)(n >> 63); |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 150 | } |
| 151 | |
Thomas Van Lenten | c8a440d | 2016-05-25 13:46:00 -0400 | [diff] [blame] | 152 | #pragma clang diagnostic push |
| 153 | #pragma clang diagnostic ignored "-Wswitch-enum" |
| 154 | #pragma clang diagnostic ignored "-Wdirect-ivar-access" |
| 155 | |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 156 | GPB_INLINE BOOL GPBDataTypeIsObject(GPBDataType type) { |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 157 | switch (type) { |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 158 | case GPBDataTypeBytes: |
| 159 | case GPBDataTypeString: |
| 160 | case GPBDataTypeMessage: |
| 161 | case GPBDataTypeGroup: |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 162 | return YES; |
| 163 | default: |
| 164 | return NO; |
| 165 | } |
| 166 | } |
| 167 | |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 168 | GPB_INLINE BOOL GPBDataTypeIsMessage(GPBDataType type) { |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 169 | switch (type) { |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 170 | case GPBDataTypeMessage: |
| 171 | case GPBDataTypeGroup: |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 172 | return YES; |
| 173 | default: |
| 174 | return NO; |
| 175 | } |
| 176 | } |
| 177 | |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 178 | GPB_INLINE BOOL GPBFieldDataTypeIsMessage(GPBFieldDescriptor *field) { |
| 179 | return GPBDataTypeIsMessage(field->description_->dataType); |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 180 | } |
| 181 | |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 182 | GPB_INLINE BOOL GPBFieldDataTypeIsObject(GPBFieldDescriptor *field) { |
| 183 | return GPBDataTypeIsObject(field->description_->dataType); |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | GPB_INLINE BOOL GPBExtensionIsMessage(GPBExtensionDescriptor *ext) { |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 187 | return GPBDataTypeIsMessage(ext->description_->dataType); |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | // The field is an array/map or it has an object value. |
| 191 | GPB_INLINE BOOL GPBFieldStoresObject(GPBFieldDescriptor *field) { |
| 192 | GPBMessageFieldDescription *desc = field->description_; |
| 193 | if ((desc->flags & (GPBFieldRepeated | GPBFieldMapKeyMask)) != 0) { |
| 194 | return YES; |
| 195 | } |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 196 | return GPBDataTypeIsObject(desc->dataType); |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | BOOL GPBGetHasIvar(GPBMessage *self, int32_t index, uint32_t fieldNumber); |
| 200 | void GPBSetHasIvar(GPBMessage *self, int32_t idx, uint32_t fieldNumber, |
| 201 | BOOL value); |
| 202 | uint32_t GPBGetHasOneof(GPBMessage *self, int32_t index); |
| 203 | |
| 204 | GPB_INLINE BOOL |
| 205 | GPBGetHasIvarField(GPBMessage *self, GPBFieldDescriptor *field) { |
| 206 | GPBMessageFieldDescription *fieldDesc = field->description_; |
| 207 | return GPBGetHasIvar(self, fieldDesc->hasIndex, fieldDesc->number); |
| 208 | } |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 209 | |
Thomas Van Lenten | c8a440d | 2016-05-25 13:46:00 -0400 | [diff] [blame] | 210 | #pragma clang diagnostic pop |
| 211 | |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 212 | //%PDDM-DEFINE GPB_IVAR_SET_DECL(NAME, TYPE) |
Thomas Van Lenten | e1e5b8a | 2020-04-10 15:55:32 -0400 | [diff] [blame] | 213 | //%void GPBSet##NAME##IvarWithFieldPrivate(GPBMessage *self, |
| 214 | //% NAME$S GPBFieldDescriptor *field, |
| 215 | //% NAME$S TYPE value); |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 216 | //%PDDM-EXPAND GPB_IVAR_SET_DECL(Bool, BOOL) |
| 217 | // This block of code is generated, do not edit it directly. |
Dave MacLachlan | ab48ecf | 2020-01-20 13:47:20 -0800 | [diff] [blame] | 218 | // clang-format off |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 219 | |
Thomas Van Lenten | e1e5b8a | 2020-04-10 15:55:32 -0400 | [diff] [blame] | 220 | void GPBSetBoolIvarWithFieldPrivate(GPBMessage *self, |
| 221 | GPBFieldDescriptor *field, |
| 222 | BOOL value); |
Dave MacLachlan | ab48ecf | 2020-01-20 13:47:20 -0800 | [diff] [blame] | 223 | // clang-format on |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 224 | //%PDDM-EXPAND GPB_IVAR_SET_DECL(Int32, int32_t) |
| 225 | // This block of code is generated, do not edit it directly. |
Dave MacLachlan | ab48ecf | 2020-01-20 13:47:20 -0800 | [diff] [blame] | 226 | // clang-format off |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 227 | |
Thomas Van Lenten | e1e5b8a | 2020-04-10 15:55:32 -0400 | [diff] [blame] | 228 | void GPBSetInt32IvarWithFieldPrivate(GPBMessage *self, |
| 229 | GPBFieldDescriptor *field, |
| 230 | int32_t value); |
Dave MacLachlan | ab48ecf | 2020-01-20 13:47:20 -0800 | [diff] [blame] | 231 | // clang-format on |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 232 | //%PDDM-EXPAND GPB_IVAR_SET_DECL(UInt32, uint32_t) |
| 233 | // This block of code is generated, do not edit it directly. |
Dave MacLachlan | ab48ecf | 2020-01-20 13:47:20 -0800 | [diff] [blame] | 234 | // clang-format off |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 235 | |
Thomas Van Lenten | e1e5b8a | 2020-04-10 15:55:32 -0400 | [diff] [blame] | 236 | void GPBSetUInt32IvarWithFieldPrivate(GPBMessage *self, |
| 237 | GPBFieldDescriptor *field, |
| 238 | uint32_t value); |
Dave MacLachlan | ab48ecf | 2020-01-20 13:47:20 -0800 | [diff] [blame] | 239 | // clang-format on |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 240 | //%PDDM-EXPAND GPB_IVAR_SET_DECL(Int64, int64_t) |
| 241 | // This block of code is generated, do not edit it directly. |
Dave MacLachlan | ab48ecf | 2020-01-20 13:47:20 -0800 | [diff] [blame] | 242 | // clang-format off |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 243 | |
Thomas Van Lenten | e1e5b8a | 2020-04-10 15:55:32 -0400 | [diff] [blame] | 244 | void GPBSetInt64IvarWithFieldPrivate(GPBMessage *self, |
| 245 | GPBFieldDescriptor *field, |
| 246 | int64_t value); |
Dave MacLachlan | ab48ecf | 2020-01-20 13:47:20 -0800 | [diff] [blame] | 247 | // clang-format on |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 248 | //%PDDM-EXPAND GPB_IVAR_SET_DECL(UInt64, uint64_t) |
| 249 | // This block of code is generated, do not edit it directly. |
Dave MacLachlan | ab48ecf | 2020-01-20 13:47:20 -0800 | [diff] [blame] | 250 | // clang-format off |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 251 | |
Thomas Van Lenten | e1e5b8a | 2020-04-10 15:55:32 -0400 | [diff] [blame] | 252 | void GPBSetUInt64IvarWithFieldPrivate(GPBMessage *self, |
| 253 | GPBFieldDescriptor *field, |
| 254 | uint64_t value); |
Dave MacLachlan | ab48ecf | 2020-01-20 13:47:20 -0800 | [diff] [blame] | 255 | // clang-format on |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 256 | //%PDDM-EXPAND GPB_IVAR_SET_DECL(Float, float) |
| 257 | // This block of code is generated, do not edit it directly. |
Dave MacLachlan | ab48ecf | 2020-01-20 13:47:20 -0800 | [diff] [blame] | 258 | // clang-format off |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 259 | |
Thomas Van Lenten | e1e5b8a | 2020-04-10 15:55:32 -0400 | [diff] [blame] | 260 | void GPBSetFloatIvarWithFieldPrivate(GPBMessage *self, |
| 261 | GPBFieldDescriptor *field, |
| 262 | float value); |
Dave MacLachlan | ab48ecf | 2020-01-20 13:47:20 -0800 | [diff] [blame] | 263 | // clang-format on |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 264 | //%PDDM-EXPAND GPB_IVAR_SET_DECL(Double, double) |
| 265 | // This block of code is generated, do not edit it directly. |
Dave MacLachlan | ab48ecf | 2020-01-20 13:47:20 -0800 | [diff] [blame] | 266 | // clang-format off |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 267 | |
Thomas Van Lenten | e1e5b8a | 2020-04-10 15:55:32 -0400 | [diff] [blame] | 268 | void GPBSetDoubleIvarWithFieldPrivate(GPBMessage *self, |
| 269 | GPBFieldDescriptor *field, |
| 270 | double value); |
Dave MacLachlan | ab48ecf | 2020-01-20 13:47:20 -0800 | [diff] [blame] | 271 | // clang-format on |
Thomas Van Lenten | e1e5b8a | 2020-04-10 15:55:32 -0400 | [diff] [blame] | 272 | //%PDDM-EXPAND-END (7 expansions) |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 273 | |
Thomas Van Lenten | e1e5b8a | 2020-04-10 15:55:32 -0400 | [diff] [blame] | 274 | void GPBSetEnumIvarWithFieldPrivate(GPBMessage *self, |
| 275 | GPBFieldDescriptor *field, |
| 276 | int32_t value); |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 277 | |
| 278 | id GPBGetObjectIvarWithField(GPBMessage *self, GPBFieldDescriptor *field); |
| 279 | |
Thomas Van Lenten | e1e5b8a | 2020-04-10 15:55:32 -0400 | [diff] [blame] | 280 | void GPBSetObjectIvarWithFieldPrivate(GPBMessage *self, |
| 281 | GPBFieldDescriptor *field, id value); |
| 282 | void GPBSetRetainedObjectIvarWithFieldPrivate(GPBMessage *self, |
| 283 | GPBFieldDescriptor *field, |
| 284 | id __attribute__((ns_consumed)) |
| 285 | value); |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 286 | |
| 287 | // GPBGetObjectIvarWithField will automatically create the field (message) if |
| 288 | // it doesn't exist. GPBGetObjectIvarWithFieldNoAutocreate will return nil. |
| 289 | id GPBGetObjectIvarWithFieldNoAutocreate(GPBMessage *self, |
| 290 | GPBFieldDescriptor *field); |
| 291 | |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 292 | // Clears and releases the autocreated message ivar, if it's autocreated. If |
| 293 | // it's not set as autocreated, this method does nothing. |
| 294 | void GPBClearAutocreatedMessageIvarWithField(GPBMessage *self, |
| 295 | GPBFieldDescriptor *field); |
| 296 | |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 297 | // Returns an Objective C encoding for |selector|. |instanceSel| should be |
| 298 | // YES if it's an instance selector (as opposed to a class selector). |
| 299 | // |selector| must be a selector from MessageSignatureProtocol. |
| 300 | const char *GPBMessageEncodingForSelector(SEL selector, BOOL instanceSel); |
| 301 | |
| 302 | // Helper for text format name encoding. |
Peter Newman | e2cc2de | 2020-08-10 19:08:25 +0100 | [diff] [blame] | 303 | // decodeData is the data describing the special decodes. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 304 | // key and inputString are the input that needs decoding. |
| 305 | NSString *GPBDecodeTextFormatName(const uint8_t *decodeData, int32_t key, |
| 306 | NSString *inputString); |
| 307 | |
Thomas Van Lenten | e1e5b8a | 2020-04-10 15:55:32 -0400 | [diff] [blame] | 308 | |
Thomas Van Lenten | 3c8e959 | 2020-04-13 10:49:16 -0400 | [diff] [blame] | 309 | // Shims from the older generated code into the runtime. |
Thomas Van Lenten | e1e5b8a | 2020-04-10 15:55:32 -0400 | [diff] [blame] | 310 | void GPBSetInt32IvarWithFieldInternal(GPBMessage *self, |
| 311 | GPBFieldDescriptor *field, |
| 312 | int32_t value, |
| 313 | GPBFileSyntax syntax); |
Thomas Van Lenten | 3c8e959 | 2020-04-13 10:49:16 -0400 | [diff] [blame] | 314 | void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof, |
| 315 | int32_t oneofHasIndex, uint32_t fieldNumberNotToClear); |
Thomas Van Lenten | e1e5b8a | 2020-04-10 15:55:32 -0400 | [diff] [blame] | 316 | |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 317 | // A series of selectors that are used solely to get @encoding values |
| 318 | // for them by the dynamic protobuf runtime code. See |
Dave MacLachlan | 37a6672 | 2017-11-14 15:16:04 -0800 | [diff] [blame] | 319 | // GPBMessageEncodingForSelector for details. GPBRootObject conforms to |
| 320 | // the protocol so that it is encoded in the Objective C runtime. |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 321 | @protocol GPBMessageSignatureProtocol |
| 322 | @optional |
| 323 | |
| 324 | #define GPB_MESSAGE_SIGNATURE_ENTRY(TYPE, NAME) \ |
| 325 | -(TYPE)get##NAME; \ |
| 326 | -(void)set##NAME : (TYPE)value; \ |
| 327 | -(TYPE)get##NAME##AtIndex : (NSUInteger)index; |
| 328 | |
| 329 | GPB_MESSAGE_SIGNATURE_ENTRY(BOOL, Bool) |
| 330 | GPB_MESSAGE_SIGNATURE_ENTRY(uint32_t, Fixed32) |
| 331 | GPB_MESSAGE_SIGNATURE_ENTRY(int32_t, SFixed32) |
| 332 | GPB_MESSAGE_SIGNATURE_ENTRY(float, Float) |
| 333 | GPB_MESSAGE_SIGNATURE_ENTRY(uint64_t, Fixed64) |
| 334 | GPB_MESSAGE_SIGNATURE_ENTRY(int64_t, SFixed64) |
| 335 | GPB_MESSAGE_SIGNATURE_ENTRY(double, Double) |
| 336 | GPB_MESSAGE_SIGNATURE_ENTRY(int32_t, Int32) |
| 337 | GPB_MESSAGE_SIGNATURE_ENTRY(int64_t, Int64) |
| 338 | GPB_MESSAGE_SIGNATURE_ENTRY(int32_t, SInt32) |
| 339 | GPB_MESSAGE_SIGNATURE_ENTRY(int64_t, SInt64) |
| 340 | GPB_MESSAGE_SIGNATURE_ENTRY(uint32_t, UInt32) |
| 341 | GPB_MESSAGE_SIGNATURE_ENTRY(uint64_t, UInt64) |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 342 | GPB_MESSAGE_SIGNATURE_ENTRY(NSData *, Bytes) |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 343 | GPB_MESSAGE_SIGNATURE_ENTRY(NSString *, String) |
| 344 | GPB_MESSAGE_SIGNATURE_ENTRY(GPBMessage *, Message) |
| 345 | GPB_MESSAGE_SIGNATURE_ENTRY(GPBMessage *, Group) |
| 346 | GPB_MESSAGE_SIGNATURE_ENTRY(int32_t, Enum) |
| 347 | |
| 348 | #undef GPB_MESSAGE_SIGNATURE_ENTRY |
| 349 | |
| 350 | - (id)getArray; |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 351 | - (NSUInteger)getArrayCount; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 352 | - (void)setArray:(NSArray *)array; |
| 353 | + (id)getClassValue; |
| 354 | @end |
| 355 | |
Thomas Van Lenten | 2d1c5e2 | 2017-03-02 14:50:10 -0500 | [diff] [blame] | 356 | BOOL GPBClassHasSel(Class aClass, SEL sel); |
| 357 | |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 358 | CF_EXTERN_C_END |