blob: 57d04dde3830943ac800f404ac676a2d486961ab [file] [log] [blame]
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001// 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 "GPBCodedInputStream_PackagePrivate.h"
32
33#import "GPBDictionary_PackagePrivate.h"
34#import "GPBMessage_PackagePrivate.h"
35#import "GPBUnknownFieldSet_PackagePrivate.h"
36#import "GPBUtilities_PackagePrivate.h"
37#import "GPBWireFormat.h"
38
Sergio Campamáe34c0912016-06-02 11:14:26 -070039NSString *const GPBCodedInputStreamException =
40 GPBNSStringifySymbol(GPBCodedInputStreamException);
41
42NSString *const GPBCodedInputStreamUnderlyingErrorKey =
43 GPBNSStringifySymbol(GPBCodedInputStreamUnderlyingErrorKey);
44
45NSString *const GPBCodedInputStreamErrorDomain =
46 GPBNSStringifySymbol(GPBCodedInputStreamErrorDomain);
47
Thomas Van Lentenddb43882017-03-28 09:10:20 -040048// Matching:
Feng Xiaoafe98de2018-08-22 11:55:30 -070049// https://github.com/protocolbuffers/protobuf/blob/master/java/core/src/main/java/com/google/protobuf/CodedInputStream.java#L62
Thomas Van Lentenddb43882017-03-28 09:10:20 -040050// private static final int DEFAULT_RECURSION_LIMIT = 100;
Feng Xiaoafe98de2018-08-22 11:55:30 -070051// https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/io/coded_stream.cc#L86
Thomas Van Lentenddb43882017-03-28 09:10:20 -040052// int CodedInputStream::default_recursion_limit_ = 100;
53static const NSUInteger kDefaultRecursionLimit = 100;
Thomas Van Lenten30650d82015-05-01 08:57:16 -040054
Sergio Campamáe34c0912016-06-02 11:14:26 -070055static void RaiseException(NSInteger code, NSString *reason) {
56 NSDictionary *errorInfo = nil;
57 if ([reason length]) {
58 errorInfo = @{ GPBErrorReasonKey: reason };
59 }
60 NSError *error = [NSError errorWithDomain:GPBCodedInputStreamErrorDomain
61 code:code
62 userInfo:errorInfo];
63
64 NSDictionary *exceptionInfo =
65 @{ GPBCodedInputStreamUnderlyingErrorKey: error };
Hiroshi Ichikawa7d978082018-05-01 00:44:41 +090066 [[NSException exceptionWithName:GPBCodedInputStreamException
67 reason:reason
68 userInfo:exceptionInfo] raise];
Sergio Campamáe34c0912016-06-02 11:14:26 -070069}
70
Sergio Campamab1f954e2017-10-05 17:47:22 -040071static void CheckRecursionLimit(GPBCodedInputStreamState *state) {
72 if (state->recursionDepth >= kDefaultRecursionLimit) {
73 RaiseException(GPBCodedInputStreamErrorRecursionDepthExceeded, nil);
74 }
75}
76
Thomas Van Lentend846b0b2015-06-08 16:24:57 -040077static void CheckSize(GPBCodedInputStreamState *state, size_t size) {
Thomas Van Lenten30650d82015-05-01 08:57:16 -040078 size_t newSize = state->bufferPos + size;
79 if (newSize > state->bufferSize) {
Sergio Campamáe34c0912016-06-02 11:14:26 -070080 RaiseException(GPBCodedInputStreamErrorInvalidSize, nil);
Thomas Van Lenten30650d82015-05-01 08:57:16 -040081 }
82 if (newSize > state->currentLimit) {
83 // Fast forward to end of currentLimit;
84 state->bufferPos = state->currentLimit;
Sergio Campamáe34c0912016-06-02 11:14:26 -070085 RaiseException(GPBCodedInputStreamErrorSubsectionLimitReached, nil);
Thomas Van Lenten30650d82015-05-01 08:57:16 -040086 }
87}
88
Thomas Van Lentend846b0b2015-06-08 16:24:57 -040089static int8_t ReadRawByte(GPBCodedInputStreamState *state) {
Thomas Van Lenten30650d82015-05-01 08:57:16 -040090 CheckSize(state, sizeof(int8_t));
91 return ((int8_t *)state->bytes)[state->bufferPos++];
92}
93
Thomas Van Lentend846b0b2015-06-08 16:24:57 -040094static int32_t ReadRawLittleEndian32(GPBCodedInputStreamState *state) {
Thomas Van Lenten30650d82015-05-01 08:57:16 -040095 CheckSize(state, sizeof(int32_t));
96 int32_t value = OSReadLittleInt32(state->bytes, state->bufferPos);
97 state->bufferPos += sizeof(int32_t);
98 return value;
99}
100
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400101static int64_t ReadRawLittleEndian64(GPBCodedInputStreamState *state) {
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400102 CheckSize(state, sizeof(int64_t));
103 int64_t value = OSReadLittleInt64(state->bytes, state->bufferPos);
104 state->bufferPos += sizeof(int64_t);
105 return value;
106}
107
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400108static int64_t ReadRawVarint64(GPBCodedInputStreamState *state) {
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400109 int32_t shift = 0;
110 int64_t result = 0;
111 while (shift < 64) {
112 int8_t b = ReadRawByte(state);
Thomas Van Lenten953adb12018-01-31 11:59:57 -0500113 result |= (int64_t)((uint64_t)(b & 0x7F) << shift);
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400114 if ((b & 0x80) == 0) {
115 return result;
116 }
117 shift += 7;
118 }
Sergio Campamáe34c0912016-06-02 11:14:26 -0700119 RaiseException(GPBCodedInputStreamErrorInvalidVarInt, @"Invalid VarInt64");
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400120 return 0;
121}
122
Sergio Campamab1f954e2017-10-05 17:47:22 -0400123static int32_t ReadRawVarint32(GPBCodedInputStreamState *state) {
124 return (int32_t)ReadRawVarint64(state);
125}
126
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400127static void SkipRawData(GPBCodedInputStreamState *state, size_t size) {
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400128 CheckSize(state, size);
129 state->bufferPos += size;
130}
131
132double GPBCodedInputStreamReadDouble(GPBCodedInputStreamState *state) {
133 int64_t value = ReadRawLittleEndian64(state);
134 return GPBConvertInt64ToDouble(value);
135}
136
137float GPBCodedInputStreamReadFloat(GPBCodedInputStreamState *state) {
138 int32_t value = ReadRawLittleEndian32(state);
139 return GPBConvertInt32ToFloat(value);
140}
141
142uint64_t GPBCodedInputStreamReadUInt64(GPBCodedInputStreamState *state) {
143 uint64_t value = ReadRawVarint64(state);
144 return value;
145}
146
147uint32_t GPBCodedInputStreamReadUInt32(GPBCodedInputStreamState *state) {
148 uint32_t value = ReadRawVarint32(state);
149 return value;
150}
151
152int64_t GPBCodedInputStreamReadInt64(GPBCodedInputStreamState *state) {
153 int64_t value = ReadRawVarint64(state);
154 return value;
155}
156
157int32_t GPBCodedInputStreamReadInt32(GPBCodedInputStreamState *state) {
158 int32_t value = ReadRawVarint32(state);
159 return value;
160}
161
162uint64_t GPBCodedInputStreamReadFixed64(GPBCodedInputStreamState *state) {
163 uint64_t value = ReadRawLittleEndian64(state);
164 return value;
165}
166
167uint32_t GPBCodedInputStreamReadFixed32(GPBCodedInputStreamState *state) {
168 uint32_t value = ReadRawLittleEndian32(state);
169 return value;
170}
171
172int32_t GPBCodedInputStreamReadEnum(GPBCodedInputStreamState *state) {
173 int32_t value = ReadRawVarint32(state);
174 return value;
175}
176
177int32_t GPBCodedInputStreamReadSFixed32(GPBCodedInputStreamState *state) {
178 int32_t value = ReadRawLittleEndian32(state);
179 return value;
180}
181
182int64_t GPBCodedInputStreamReadSFixed64(GPBCodedInputStreamState *state) {
183 int64_t value = ReadRawLittleEndian64(state);
184 return value;
185}
186
187int32_t GPBCodedInputStreamReadSInt32(GPBCodedInputStreamState *state) {
188 int32_t value = GPBDecodeZigZag32(ReadRawVarint32(state));
189 return value;
190}
191
192int64_t GPBCodedInputStreamReadSInt64(GPBCodedInputStreamState *state) {
193 int64_t value = GPBDecodeZigZag64(ReadRawVarint64(state));
194 return value;
195}
196
197BOOL GPBCodedInputStreamReadBool(GPBCodedInputStreamState *state) {
198 return ReadRawVarint32(state) != 0;
199}
200
201int32_t GPBCodedInputStreamReadTag(GPBCodedInputStreamState *state) {
202 if (GPBCodedInputStreamIsAtEnd(state)) {
203 state->lastTag = 0;
204 return 0;
205 }
206
207 state->lastTag = ReadRawVarint32(state);
Thomas Van Lentenecc0f542017-06-06 10:14:41 -0400208 // Tags have to include a valid wireformat.
Thomas Van Lentenc18aa772016-06-29 09:51:13 -0400209 if (!GPBWireFormatIsValidTag(state->lastTag)) {
210 RaiseException(GPBCodedInputStreamErrorInvalidTag,
211 @"Invalid wireformat in tag.");
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400212 }
Thomas Van Lentenecc0f542017-06-06 10:14:41 -0400213 // Zero is not a valid field number.
214 if (GPBWireFormatGetTagFieldNumber(state->lastTag) == 0) {
215 RaiseException(GPBCodedInputStreamErrorInvalidTag,
216 @"A zero field number on the wire is invalid.");
217 }
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400218 return state->lastTag;
219}
220
221NSString *GPBCodedInputStreamReadRetainedString(
222 GPBCodedInputStreamState *state) {
223 int32_t size = ReadRawVarint32(state);
224 NSString *result;
225 if (size == 0) {
226 result = @"";
227 } else {
228 CheckSize(state, size);
Thomas Van Lentend6590d62015-12-17 14:35:44 -0500229 result = [[NSString alloc] initWithBytes:&state->bytes[state->bufferPos]
230 length:size
231 encoding:NSUTF8StringEncoding];
Thomas Van Lentenc9167f22016-04-05 17:04:36 -0400232 state->bufferPos += size;
Thomas Van Lentend6590d62015-12-17 14:35:44 -0500233 if (!result) {
Thomas Van Lentend6590d62015-12-17 14:35:44 -0500234#ifdef DEBUG
235 // https://developers.google.com/protocol-buffers/docs/proto#scalar
Thomas Van Lentenc9167f22016-04-05 17:04:36 -0400236 NSLog(@"UTF-8 failure, is some field type 'string' when it should be "
Thomas Van Lentend6590d62015-12-17 14:35:44 -0500237 @"'bytes'?");
238#endif
Sergio Campamáe34c0912016-06-02 11:14:26 -0700239 RaiseException(GPBCodedInputStreamErrorInvalidUTF8, nil);
Thomas Van Lentend6590d62015-12-17 14:35:44 -0500240 }
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400241 }
242 return result;
243}
244
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400245NSData *GPBCodedInputStreamReadRetainedBytes(GPBCodedInputStreamState *state) {
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400246 int32_t size = ReadRawVarint32(state);
247 if (size < 0) return nil;
248 CheckSize(state, size);
249 NSData *result = [[NSData alloc] initWithBytes:state->bytes + state->bufferPos
250 length:size];
251 state->bufferPos += size;
252 return result;
253}
254
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400255NSData *GPBCodedInputStreamReadRetainedBytesNoCopy(
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400256 GPBCodedInputStreamState *state) {
257 int32_t size = ReadRawVarint32(state);
258 if (size < 0) return nil;
259 CheckSize(state, size);
260 // Cast is safe because freeWhenDone is NO.
261 NSData *result = [[NSData alloc]
262 initWithBytesNoCopy:(void *)(state->bytes + state->bufferPos)
263 length:size
264 freeWhenDone:NO];
265 state->bufferPos += size;
266 return result;
267}
268
269size_t GPBCodedInputStreamPushLimit(GPBCodedInputStreamState *state,
270 size_t byteLimit) {
271 byteLimit += state->bufferPos;
272 size_t oldLimit = state->currentLimit;
273 if (byteLimit > oldLimit) {
Sergio Campamáe34c0912016-06-02 11:14:26 -0700274 RaiseException(GPBCodedInputStreamErrorInvalidSubsectionLimit, nil);
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400275 }
276 state->currentLimit = byteLimit;
277 return oldLimit;
278}
279
280void GPBCodedInputStreamPopLimit(GPBCodedInputStreamState *state,
281 size_t oldLimit) {
282 state->currentLimit = oldLimit;
283}
284
285size_t GPBCodedInputStreamBytesUntilLimit(GPBCodedInputStreamState *state) {
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400286 return state->currentLimit - state->bufferPos;
287}
288
289BOOL GPBCodedInputStreamIsAtEnd(GPBCodedInputStreamState *state) {
290 return (state->bufferPos == state->bufferSize) ||
291 (state->bufferPos == state->currentLimit);
292}
293
294void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state,
295 int32_t value) {
296 if (state->lastTag != value) {
Sergio Campamáe34c0912016-06-02 11:14:26 -0700297 RaiseException(GPBCodedInputStreamErrorInvalidTag, @"Unexpected tag read");
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400298 }
299}
300
301@implementation GPBCodedInputStream
302
303+ (instancetype)streamWithData:(NSData *)data {
304 return [[[self alloc] initWithData:data] autorelease];
305}
306
307- (instancetype)initWithData:(NSData *)data {
308 if ((self = [super init])) {
309#ifdef DEBUG
310 NSCAssert([self class] == [GPBCodedInputStream class],
311 @"Subclassing of GPBCodedInputStream is not allowed.");
312#endif
313 buffer_ = [data retain];
314 state_.bytes = (const uint8_t *)[data bytes];
315 state_.bufferSize = [data length];
Thomas Van Lentenba800e22015-11-23 12:23:27 -0500316 state_.currentLimit = state_.bufferSize;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400317 }
318 return self;
319}
320
321- (void)dealloc {
322 [buffer_ release];
323 [super dealloc];
324}
325
Thomas Van Lentenc8a440d2016-05-25 13:46:00 -0400326// Direct access is use for speed, to avoid even internally declaring things
327// read/write, etc. The warning is enabled in the project to ensure code calling
328// protos can turn on -Wdirect-ivar-access without issues.
329#pragma clang diagnostic push
330#pragma clang diagnostic ignored "-Wdirect-ivar-access"
331
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400332- (int32_t)readTag {
333 return GPBCodedInputStreamReadTag(&state_);
334}
335
336- (void)checkLastTagWas:(int32_t)value {
337 GPBCodedInputStreamCheckLastTagWas(&state_, value);
338}
339
340- (BOOL)skipField:(int32_t)tag {
Thomas Van Lentenc18aa772016-06-29 09:51:13 -0400341 NSAssert(GPBWireFormatIsValidTag(tag), @"Invalid tag");
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400342 switch (GPBWireFormatGetTagWireType(tag)) {
343 case GPBWireFormatVarint:
344 GPBCodedInputStreamReadInt32(&state_);
345 return YES;
346 case GPBWireFormatFixed64:
347 SkipRawData(&state_, sizeof(int64_t));
348 return YES;
349 case GPBWireFormatLengthDelimited:
350 SkipRawData(&state_, ReadRawVarint32(&state_));
351 return YES;
352 case GPBWireFormatStartGroup:
353 [self skipMessage];
354 GPBCodedInputStreamCheckLastTagWas(
355 &state_, GPBWireFormatMakeTag(GPBWireFormatGetTagFieldNumber(tag),
356 GPBWireFormatEndGroup));
357 return YES;
358 case GPBWireFormatEndGroup:
359 return NO;
360 case GPBWireFormatFixed32:
361 SkipRawData(&state_, sizeof(int32_t));
362 return YES;
363 }
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400364}
365
366- (void)skipMessage {
367 while (YES) {
368 int32_t tag = GPBCodedInputStreamReadTag(&state_);
369 if (tag == 0 || ![self skipField:tag]) {
370 return;
371 }
372 }
373}
374
Thomas Van Lenten331cee52016-04-01 12:26:15 -0400375- (BOOL)isAtEnd {
376 return GPBCodedInputStreamIsAtEnd(&state_);
377}
378
379- (size_t)position {
380 return state_.bufferPos;
381}
382
Sergio Campamád58b92a2016-10-27 16:06:45 -0400383- (size_t)pushLimit:(size_t)byteLimit {
384 return GPBCodedInputStreamPushLimit(&state_, byteLimit);
385}
386
387- (void)popLimit:(size_t)oldLimit {
388 GPBCodedInputStreamPopLimit(&state_, oldLimit);
389}
390
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400391- (double)readDouble {
392 return GPBCodedInputStreamReadDouble(&state_);
393}
394
395- (float)readFloat {
396 return GPBCodedInputStreamReadFloat(&state_);
397}
398
399- (uint64_t)readUInt64 {
400 return GPBCodedInputStreamReadUInt64(&state_);
401}
402
403- (int64_t)readInt64 {
404 return GPBCodedInputStreamReadInt64(&state_);
405}
406
407- (int32_t)readInt32 {
408 return GPBCodedInputStreamReadInt32(&state_);
409}
410
411- (uint64_t)readFixed64 {
412 return GPBCodedInputStreamReadFixed64(&state_);
413}
414
415- (uint32_t)readFixed32 {
416 return GPBCodedInputStreamReadFixed32(&state_);
417}
418
419- (BOOL)readBool {
420 return GPBCodedInputStreamReadBool(&state_);
421}
422
423- (NSString *)readString {
424 return [GPBCodedInputStreamReadRetainedString(&state_) autorelease];
425}
426
427- (void)readGroup:(int32_t)fieldNumber
428 message:(GPBMessage *)message
429 extensionRegistry:(GPBExtensionRegistry *)extensionRegistry {
Sergio Campamab1f954e2017-10-05 17:47:22 -0400430 CheckRecursionLimit(&state_);
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400431 ++state_.recursionDepth;
432 [message mergeFromCodedInputStream:self extensionRegistry:extensionRegistry];
433 GPBCodedInputStreamCheckLastTagWas(
434 &state_, GPBWireFormatMakeTag(fieldNumber, GPBWireFormatEndGroup));
435 --state_.recursionDepth;
436}
437
438- (void)readUnknownGroup:(int32_t)fieldNumber
439 message:(GPBUnknownFieldSet *)message {
Sergio Campamab1f954e2017-10-05 17:47:22 -0400440 CheckRecursionLimit(&state_);
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400441 ++state_.recursionDepth;
442 [message mergeFromCodedInputStream:self];
443 GPBCodedInputStreamCheckLastTagWas(
444 &state_, GPBWireFormatMakeTag(fieldNumber, GPBWireFormatEndGroup));
445 --state_.recursionDepth;
446}
447
448- (void)readMessage:(GPBMessage *)message
449 extensionRegistry:(GPBExtensionRegistry *)extensionRegistry {
Sergio Campamab1f954e2017-10-05 17:47:22 -0400450 CheckRecursionLimit(&state_);
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400451 int32_t length = ReadRawVarint32(&state_);
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400452 size_t oldLimit = GPBCodedInputStreamPushLimit(&state_, length);
453 ++state_.recursionDepth;
454 [message mergeFromCodedInputStream:self extensionRegistry:extensionRegistry];
455 GPBCodedInputStreamCheckLastTagWas(&state_, 0);
456 --state_.recursionDepth;
457 GPBCodedInputStreamPopLimit(&state_, oldLimit);
458}
459
460- (void)readMapEntry:(id)mapDictionary
461 extensionRegistry:(GPBExtensionRegistry *)extensionRegistry
462 field:(GPBFieldDescriptor *)field
463 parentMessage:(GPBMessage *)parentMessage {
Sergio Campamab1f954e2017-10-05 17:47:22 -0400464 CheckRecursionLimit(&state_);
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400465 int32_t length = ReadRawVarint32(&state_);
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400466 size_t oldLimit = GPBCodedInputStreamPushLimit(&state_, length);
467 ++state_.recursionDepth;
468 GPBDictionaryReadEntry(mapDictionary, self, extensionRegistry, field,
469 parentMessage);
470 GPBCodedInputStreamCheckLastTagWas(&state_, 0);
471 --state_.recursionDepth;
472 GPBCodedInputStreamPopLimit(&state_, oldLimit);
473}
474
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400475- (NSData *)readBytes {
476 return [GPBCodedInputStreamReadRetainedBytes(&state_) autorelease];
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400477}
478
479- (uint32_t)readUInt32 {
480 return GPBCodedInputStreamReadUInt32(&state_);
481}
482
483- (int32_t)readEnum {
484 return GPBCodedInputStreamReadEnum(&state_);
485}
486
487- (int32_t)readSFixed32 {
488 return GPBCodedInputStreamReadSFixed32(&state_);
489}
490
491- (int64_t)readSFixed64 {
492 return GPBCodedInputStreamReadSFixed64(&state_);
493}
494
495- (int32_t)readSInt32 {
496 return GPBCodedInputStreamReadSInt32(&state_);
497}
498
499- (int64_t)readSInt64 {
500 return GPBCodedInputStreamReadSInt64(&state_);
501}
502
Thomas Van Lentenc8a440d2016-05-25 13:46:00 -0400503#pragma clang diagnostic pop
504
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400505@end