-
Notifications
You must be signed in to change notification settings - Fork 15.6k
/
GPBStruct.pbobjc.m
311 lines (273 loc) · 10.5 KB
/
GPBStruct.pbobjc.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/struct.proto
// This CPP symbol can be defined to use imports that match up to the framework
// imports needed when using CocoaPods.
#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
#define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
#endif
#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
#import <Protobuf/GPBProtocolBuffers_RuntimeSupport.h>
#else
#import "GPBProtocolBuffers_RuntimeSupport.h"
#endif
#import <stdatomic.h>
#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
#import <Protobuf/GPBStruct.pbobjc.h>
#else
#import "GPBStruct.pbobjc.h"
#endif
// @@protoc_insertion_point(imports)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
#pragma clang diagnostic ignored "-Wdollar-in-identifier-extension"
#pragma mark - Objective C Class declarations
// Forward declarations of Objective C classes that we can use as
// static values in struct initializers.
// We don't use [Foo class] because it is not a static value.
GPBObjCClassDeclaration(GPBListValue);
GPBObjCClassDeclaration(GPBStruct);
GPBObjCClassDeclaration(GPBValue);
#pragma mark - GPBStructRoot
@implementation GPBStructRoot
// No extensions in the file and no imports, so no need to generate
// +extensionRegistry.
@end
#pragma mark - GPBStructRoot_FileDescriptor
static GPBFileDescriptor *GPBStructRoot_FileDescriptor(void) {
// This is called by +initialize so there is no need to worry
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"google.protobuf"
objcPrefix:@"GPB"
syntax:GPBFileSyntaxProto3];
}
return descriptor;
}
#pragma mark - Enum GPBNullValue
GPBEnumDescriptor *GPBNullValue_EnumDescriptor(void) {
static _Atomic(GPBEnumDescriptor*) descriptor = nil;
if (!descriptor) {
static const char *valueNames =
"NullValue\000";
static const int32_t values[] = {
GPBNullValue_NullValue,
};
GPBEnumDescriptor *worker =
[GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(GPBNullValue)
valueNames:valueNames
values:values
count:(uint32_t)(sizeof(values) / sizeof(int32_t))
enumVerifier:GPBNullValue_IsValidValue];
GPBEnumDescriptor *expected = nil;
if (!atomic_compare_exchange_strong(&descriptor, &expected, worker)) {
[worker release];
}
}
return descriptor;
}
BOOL GPBNullValue_IsValidValue(int32_t value__) {
switch (value__) {
case GPBNullValue_NullValue:
return YES;
default:
return NO;
}
}
#pragma mark - GPBStruct
@implementation GPBStruct
@dynamic fields, fields_Count;
typedef struct GPBStruct__storage_ {
uint32_t _has_storage_[1];
NSMutableDictionary *fields;
} GPBStruct__storage_;
// This method is threadsafe because it is initially called
// in +initialize for each subclass.
+ (GPBDescriptor *)descriptor {
static GPBDescriptor *descriptor = nil;
if (!descriptor) {
static GPBMessageFieldDescription fields[] = {
{
.name = "fields",
.dataTypeSpecific.clazz = GPBObjCClass(GPBValue),
.number = GPBStruct_FieldNumber_Fields,
.hasIndex = GPBNoHasBit,
.offset = (uint32_t)offsetof(GPBStruct__storage_, fields),
.flags = GPBFieldMapKeyString,
.dataType = GPBDataTypeMessage,
},
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBStruct class]
rootClass:[GPBStructRoot class]
file:GPBStructRoot_FileDescriptor()
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBStruct__storage_)
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
#if defined(DEBUG) && DEBUG
NSAssert(descriptor == nil, @"Startup recursed!");
#endif // DEBUG
descriptor = localDescriptor;
}
return descriptor;
}
@end
#pragma mark - GPBValue
@implementation GPBValue
@dynamic kindOneOfCase;
@dynamic nullValue;
@dynamic numberValue;
@dynamic stringValue;
@dynamic boolValue;
@dynamic structValue;
@dynamic listValue;
typedef struct GPBValue__storage_ {
uint32_t _has_storage_[2];
GPBNullValue nullValue;
NSString *stringValue;
GPBStruct *structValue;
GPBListValue *listValue;
double numberValue;
} GPBValue__storage_;
// This method is threadsafe because it is initially called
// in +initialize for each subclass.
+ (GPBDescriptor *)descriptor {
static GPBDescriptor *descriptor = nil;
if (!descriptor) {
static GPBMessageFieldDescription fields[] = {
{
.name = "nullValue",
.dataTypeSpecific.enumDescFunc = GPBNullValue_EnumDescriptor,
.number = GPBValue_FieldNumber_NullValue,
.hasIndex = -1,
.offset = (uint32_t)offsetof(GPBValue__storage_, nullValue),
.flags = (GPBFieldFlags)(GPBFieldOptional | GPBFieldHasEnumDescriptor),
.dataType = GPBDataTypeEnum,
},
{
.name = "numberValue",
.dataTypeSpecific.clazz = Nil,
.number = GPBValue_FieldNumber_NumberValue,
.hasIndex = -1,
.offset = (uint32_t)offsetof(GPBValue__storage_, numberValue),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeDouble,
},
{
.name = "stringValue",
.dataTypeSpecific.clazz = Nil,
.number = GPBValue_FieldNumber_StringValue,
.hasIndex = -1,
.offset = (uint32_t)offsetof(GPBValue__storage_, stringValue),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
},
{
.name = "boolValue",
.dataTypeSpecific.clazz = Nil,
.number = GPBValue_FieldNumber_BoolValue,
.hasIndex = -1,
.offset = 0, // Stored in _has_storage_ to save space.
.flags = GPBFieldOptional,
.dataType = GPBDataTypeBool,
},
{
.name = "structValue",
.dataTypeSpecific.clazz = GPBObjCClass(GPBStruct),
.number = GPBValue_FieldNumber_StructValue,
.hasIndex = -1,
.offset = (uint32_t)offsetof(GPBValue__storage_, structValue),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeMessage,
},
{
.name = "listValue",
.dataTypeSpecific.clazz = GPBObjCClass(GPBListValue),
.number = GPBValue_FieldNumber_ListValue,
.hasIndex = -1,
.offset = (uint32_t)offsetof(GPBValue__storage_, listValue),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeMessage,
},
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBValue class]
rootClass:[GPBStructRoot class]
file:GPBStructRoot_FileDescriptor()
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBValue__storage_)
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
static const char *oneofs[] = {
"kind",
};
[localDescriptor setupOneofs:oneofs
count:(uint32_t)(sizeof(oneofs) / sizeof(char*))
firstHasIndex:-1];
#if defined(DEBUG) && DEBUG
NSAssert(descriptor == nil, @"Startup recursed!");
#endif // DEBUG
descriptor = localDescriptor;
}
return descriptor;
}
@end
int32_t GPBValue_NullValue_RawValue(GPBValue *message) {
GPBDescriptor *descriptor = [GPBValue descriptor];
GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBValue_FieldNumber_NullValue];
return GPBGetMessageRawEnumField(message, field);
}
void SetGPBValue_NullValue_RawValue(GPBValue *message, int32_t value) {
GPBDescriptor *descriptor = [GPBValue descriptor];
GPBFieldDescriptor *field = [descriptor fieldWithNumber:GPBValue_FieldNumber_NullValue];
GPBSetMessageRawEnumField(message, field, value);
}
void GPBValue_ClearKindOneOfCase(GPBValue *message) {
GPBDescriptor *descriptor = [GPBValue descriptor];
GPBOneofDescriptor *oneof = [descriptor.oneofs objectAtIndex:0];
GPBClearOneof(message, oneof);
}
#pragma mark - GPBListValue
@implementation GPBListValue
@dynamic valuesArray, valuesArray_Count;
typedef struct GPBListValue__storage_ {
uint32_t _has_storage_[1];
NSMutableArray *valuesArray;
} GPBListValue__storage_;
// This method is threadsafe because it is initially called
// in +initialize for each subclass.
+ (GPBDescriptor *)descriptor {
static GPBDescriptor *descriptor = nil;
if (!descriptor) {
static GPBMessageFieldDescription fields[] = {
{
.name = "valuesArray",
.dataTypeSpecific.clazz = GPBObjCClass(GPBValue),
.number = GPBListValue_FieldNumber_ValuesArray,
.hasIndex = GPBNoHasBit,
.offset = (uint32_t)offsetof(GPBListValue__storage_, valuesArray),
.flags = GPBFieldRepeated,
.dataType = GPBDataTypeMessage,
},
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[GPBListValue class]
rootClass:[GPBStructRoot class]
file:GPBStructRoot_FileDescriptor()
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(GPBListValue__storage_)
flags:(GPBDescriptorInitializationFlags)(GPBDescriptorInitializationFlag_UsesClassRefs | GPBDescriptorInitializationFlag_Proto3OptionalKnown)];
#if defined(DEBUG) && DEBUG
NSAssert(descriptor == nil, @"Startup recursed!");
#endif // DEBUG
descriptor = localDescriptor;
}
return descriptor;
}
@end
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)