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