GPBCodedInputStream.m 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2008 Google Inc. All rights reserved.
  3. //
  4. // Use of this source code is governed by a BSD-style
  5. // license that can be found in the LICENSE file or at
  6. // https://developers.google.com/open-source/licenses/bsd
  7. #import "GPBCodedInputStream.h"
  8. #import "GPBCodedInputStream_PackagePrivate.h"
  9. #import "GPBDictionary.h"
  10. #import "GPBDictionary_PackagePrivate.h"
  11. #import "GPBMessage.h"
  12. #import "GPBMessage_PackagePrivate.h"
  13. #import "GPBUnknownFieldSet.h"
  14. #import "GPBUnknownFieldSet_PackagePrivate.h"
  15. #import "GPBUtilities.h"
  16. #import "GPBUtilities_PackagePrivate.h"
  17. #import "GPBWireFormat.h"
  18. // TODO: Consider using on other functions to reduce bloat when
  19. // some compiler optimizations are enabled.
  20. #define GPB_NOINLINE __attribute__((noinline))
  21. NSString *const GPBCodedInputStreamException = GPBNSStringifySymbol(GPBCodedInputStreamException);
  22. NSString *const GPBCodedInputStreamUnderlyingErrorKey =
  23. GPBNSStringifySymbol(GPBCodedInputStreamUnderlyingErrorKey);
  24. NSString *const GPBCodedInputStreamErrorDomain =
  25. GPBNSStringifySymbol(GPBCodedInputStreamErrorDomain);
  26. // Matching:
  27. // https://github.com/protocolbuffers/protobuf/blob/main/java/core/src/main/java/com/google/protobuf/CodedInputStream.java#L62
  28. // private static final int DEFAULT_RECURSION_LIMIT = 100;
  29. // https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/io/coded_stream.cc#L86
  30. // int CodedInputStream::default_recursion_limit_ = 100;
  31. static const NSUInteger kDefaultRecursionLimit = 100;
  32. GPB_NOINLINE
  33. void GPBRaiseStreamError(NSInteger code, NSString *reason) {
  34. NSDictionary *errorInfo = nil;
  35. if ([reason length]) {
  36. errorInfo = @{GPBErrorReasonKey : reason};
  37. }
  38. NSError *error = [NSError errorWithDomain:GPBCodedInputStreamErrorDomain
  39. code:code
  40. userInfo:errorInfo];
  41. NSDictionary *exceptionInfo = @{GPBCodedInputStreamUnderlyingErrorKey : error};
  42. [[NSException exceptionWithName:GPBCodedInputStreamException reason:reason
  43. userInfo:exceptionInfo] raise];
  44. }
  45. GPB_INLINE void CheckRecursionLimit(GPBCodedInputStreamState *state) {
  46. if (state->recursionDepth >= kDefaultRecursionLimit) {
  47. GPBRaiseStreamError(GPBCodedInputStreamErrorRecursionDepthExceeded, nil);
  48. }
  49. }
  50. GPB_INLINE void CheckFieldSize(uint64_t size) {
  51. // Bytes and Strings have a max size of 2GB. And since messages are on the wire as bytes/length
  52. // delimited, they also have a 2GB size limit. The C++ does the same sort of enforcement (see
  53. // parse_context, delimited_message_util, message_lite, etc.).
  54. // https://protobuf.dev/programming-guides/encoding/#cheat-sheet
  55. if (size > 0x7fffffff) {
  56. // TODO: Maybe a different error code for this, but adding one is a breaking
  57. // change so reuse an existing one.
  58. GPBRaiseStreamError(GPBCodedInputStreamErrorInvalidSize, nil);
  59. }
  60. }
  61. static void CheckSize(GPBCodedInputStreamState *state, size_t size) {
  62. size_t newSize = state->bufferPos + size;
  63. if (newSize > state->bufferSize) {
  64. GPBRaiseStreamError(GPBCodedInputStreamErrorInvalidSize, nil);
  65. }
  66. if (newSize > state->currentLimit) {
  67. // Fast forward to end of currentLimit;
  68. state->bufferPos = state->currentLimit;
  69. GPBRaiseStreamError(GPBCodedInputStreamErrorSubsectionLimitReached, nil);
  70. }
  71. }
  72. static int8_t ReadRawByte(GPBCodedInputStreamState *state) {
  73. CheckSize(state, sizeof(int8_t));
  74. return ((int8_t *)state->bytes)[state->bufferPos++];
  75. }
  76. static int32_t ReadRawLittleEndian32(GPBCodedInputStreamState *state) {
  77. CheckSize(state, sizeof(int32_t));
  78. // Not using OSReadLittleInt32 because it has undocumented dependency
  79. // on reads being aligned.
  80. int32_t value;
  81. memcpy(&value, state->bytes + state->bufferPos, sizeof(int32_t));
  82. value = OSSwapLittleToHostInt32(value);
  83. state->bufferPos += sizeof(int32_t);
  84. return value;
  85. }
  86. static int64_t ReadRawLittleEndian64(GPBCodedInputStreamState *state) {
  87. CheckSize(state, sizeof(int64_t));
  88. // Not using OSReadLittleInt64 because it has undocumented dependency
  89. // on reads being aligned.
  90. int64_t value;
  91. memcpy(&value, state->bytes + state->bufferPos, sizeof(int64_t));
  92. value = OSSwapLittleToHostInt64(value);
  93. state->bufferPos += sizeof(int64_t);
  94. return value;
  95. }
  96. static int64_t ReadRawVarint64(GPBCodedInputStreamState *state) {
  97. int32_t shift = 0;
  98. int64_t result = 0;
  99. while (shift < 64) {
  100. int8_t b = ReadRawByte(state);
  101. result |= (int64_t)((uint64_t)(b & 0x7F) << shift);
  102. if ((b & 0x80) == 0) {
  103. return result;
  104. }
  105. shift += 7;
  106. }
  107. GPBRaiseStreamError(GPBCodedInputStreamErrorInvalidVarInt, @"Invalid VarInt64");
  108. return 0;
  109. }
  110. static int32_t ReadRawVarint32(GPBCodedInputStreamState *state) {
  111. return (int32_t)ReadRawVarint64(state);
  112. }
  113. static void SkipRawData(GPBCodedInputStreamState *state, size_t size) {
  114. CheckSize(state, size);
  115. state->bufferPos += size;
  116. }
  117. double GPBCodedInputStreamReadDouble(GPBCodedInputStreamState *state) {
  118. int64_t value = ReadRawLittleEndian64(state);
  119. return GPBConvertInt64ToDouble(value);
  120. }
  121. float GPBCodedInputStreamReadFloat(GPBCodedInputStreamState *state) {
  122. int32_t value = ReadRawLittleEndian32(state);
  123. return GPBConvertInt32ToFloat(value);
  124. }
  125. uint64_t GPBCodedInputStreamReadUInt64(GPBCodedInputStreamState *state) {
  126. uint64_t value = ReadRawVarint64(state);
  127. return value;
  128. }
  129. uint32_t GPBCodedInputStreamReadUInt32(GPBCodedInputStreamState *state) {
  130. uint32_t value = ReadRawVarint32(state);
  131. return value;
  132. }
  133. int64_t GPBCodedInputStreamReadInt64(GPBCodedInputStreamState *state) {
  134. int64_t value = ReadRawVarint64(state);
  135. return value;
  136. }
  137. int32_t GPBCodedInputStreamReadInt32(GPBCodedInputStreamState *state) {
  138. int32_t value = ReadRawVarint32(state);
  139. return value;
  140. }
  141. uint64_t GPBCodedInputStreamReadFixed64(GPBCodedInputStreamState *state) {
  142. uint64_t value = ReadRawLittleEndian64(state);
  143. return value;
  144. }
  145. uint32_t GPBCodedInputStreamReadFixed32(GPBCodedInputStreamState *state) {
  146. uint32_t value = ReadRawLittleEndian32(state);
  147. return value;
  148. }
  149. int32_t GPBCodedInputStreamReadEnum(GPBCodedInputStreamState *state) {
  150. int32_t value = ReadRawVarint32(state);
  151. return value;
  152. }
  153. int32_t GPBCodedInputStreamReadSFixed32(GPBCodedInputStreamState *state) {
  154. int32_t value = ReadRawLittleEndian32(state);
  155. return value;
  156. }
  157. int64_t GPBCodedInputStreamReadSFixed64(GPBCodedInputStreamState *state) {
  158. int64_t value = ReadRawLittleEndian64(state);
  159. return value;
  160. }
  161. int32_t GPBCodedInputStreamReadSInt32(GPBCodedInputStreamState *state) {
  162. int32_t value = GPBDecodeZigZag32(ReadRawVarint32(state));
  163. return value;
  164. }
  165. int64_t GPBCodedInputStreamReadSInt64(GPBCodedInputStreamState *state) {
  166. int64_t value = GPBDecodeZigZag64(ReadRawVarint64(state));
  167. return value;
  168. }
  169. BOOL GPBCodedInputStreamReadBool(GPBCodedInputStreamState *state) {
  170. return ReadRawVarint64(state) != 0;
  171. }
  172. int32_t GPBCodedInputStreamReadTag(GPBCodedInputStreamState *state) {
  173. if (GPBCodedInputStreamIsAtEnd(state)) {
  174. state->lastTag = 0;
  175. return 0;
  176. }
  177. state->lastTag = ReadRawVarint32(state);
  178. // Tags have to include a valid wireformat.
  179. if (!GPBWireFormatIsValidTag(state->lastTag)) {
  180. GPBRaiseStreamError(GPBCodedInputStreamErrorInvalidTag, @"Invalid wireformat in tag.");
  181. }
  182. // Zero is not a valid field number.
  183. if (GPBWireFormatGetTagFieldNumber(state->lastTag) == 0) {
  184. GPBRaiseStreamError(GPBCodedInputStreamErrorInvalidTag,
  185. @"A zero field number on the wire is invalid.");
  186. }
  187. return state->lastTag;
  188. }
  189. NSString *GPBCodedInputStreamReadRetainedString(GPBCodedInputStreamState *state) {
  190. uint64_t size = GPBCodedInputStreamReadUInt64(state);
  191. CheckFieldSize(size);
  192. NSUInteger ns_size = (NSUInteger)size;
  193. NSString *result;
  194. if (size == 0) {
  195. result = @"";
  196. } else {
  197. size_t size2 = (size_t)size; // Cast safe on 32bit because of CheckFieldSize() above.
  198. CheckSize(state, size2);
  199. result = [[NSString alloc] initWithBytes:&state->bytes[state->bufferPos]
  200. length:ns_size
  201. encoding:NSUTF8StringEncoding];
  202. state->bufferPos += size;
  203. if (!result) {
  204. #ifdef DEBUG
  205. // https://developers.google.com/protocol-buffers/docs/proto#scalar
  206. NSLog(@"UTF-8 failure, is some field type 'string' when it should be "
  207. @"'bytes'?");
  208. #endif
  209. GPBRaiseStreamError(GPBCodedInputStreamErrorInvalidUTF8, nil);
  210. }
  211. }
  212. return result;
  213. }
  214. NSData *GPBCodedInputStreamReadRetainedBytes(GPBCodedInputStreamState *state) {
  215. uint64_t size = GPBCodedInputStreamReadUInt64(state);
  216. CheckFieldSize(size);
  217. size_t size2 = (size_t)size; // Cast safe on 32bit because of CheckFieldSize() above.
  218. CheckSize(state, size2);
  219. NSUInteger ns_size = (NSUInteger)size;
  220. NSData *result = [[NSData alloc] initWithBytes:state->bytes + state->bufferPos length:ns_size];
  221. state->bufferPos += size;
  222. return result;
  223. }
  224. NSData *GPBCodedInputStreamReadRetainedBytesNoCopy(GPBCodedInputStreamState *state) {
  225. uint64_t size = GPBCodedInputStreamReadUInt64(state);
  226. CheckFieldSize(size);
  227. size_t size2 = (size_t)size; // Cast safe on 32bit because of CheckFieldSize() above.
  228. CheckSize(state, size2);
  229. NSUInteger ns_size = (NSUInteger)size;
  230. // Cast is safe because freeWhenDone is NO.
  231. NSData *result = [[NSData alloc] initWithBytesNoCopy:(void *)(state->bytes + state->bufferPos)
  232. length:ns_size
  233. freeWhenDone:NO];
  234. state->bufferPos += size;
  235. return result;
  236. }
  237. static void SkipToEndGroupInternal(GPBCodedInputStreamState *state, uint32_t endGroupTag) {
  238. CheckRecursionLimit(state);
  239. ++state->recursionDepth;
  240. while (YES) {
  241. uint32_t tag = GPBCodedInputStreamReadTag(state);
  242. if (tag == endGroupTag || tag == 0) {
  243. GPBCodedInputStreamCheckLastTagWas(state, endGroupTag); // Will fail for end of input.
  244. --state->recursionDepth;
  245. return;
  246. }
  247. switch (GPBWireFormatGetTagWireType(tag)) {
  248. case GPBWireFormatVarint:
  249. (void)ReadRawVarint64(state);
  250. break;
  251. case GPBWireFormatFixed64:
  252. SkipRawData(state, sizeof(uint64_t));
  253. break;
  254. case GPBWireFormatLengthDelimited: {
  255. uint64_t size = ReadRawVarint64(state);
  256. CheckFieldSize(size);
  257. size_t size2 = (size_t)size; // Cast safe on 32bit because of CheckFieldSize() above.
  258. SkipRawData(state, size2);
  259. break;
  260. }
  261. case GPBWireFormatStartGroup:
  262. SkipToEndGroupInternal(state, GPBWireFormatMakeTag(GPBWireFormatGetTagFieldNumber(tag),
  263. GPBWireFormatEndGroup));
  264. break;
  265. case GPBWireFormatEndGroup:
  266. GPBRaiseStreamError(GPBCodedInputStreamErrorInvalidTag, @"Unmatched end group");
  267. break;
  268. case GPBWireFormatFixed32:
  269. SkipRawData(state, sizeof(uint32_t));
  270. break;
  271. }
  272. }
  273. }
  274. // This doesn't include the start group, but it collects all bytes until the end group including
  275. // the end group tag.
  276. NSData *GPBCodedInputStreamReadRetainedBytesToEndGroupNoCopy(GPBCodedInputStreamState *state,
  277. int32_t fieldNumber) {
  278. // Better have just read the start of the group.
  279. GPBCodedInputStreamCheckLastTagWas(state,
  280. GPBWireFormatMakeTag(fieldNumber, GPBWireFormatStartGroup));
  281. const uint8_t *start = state->bytes + state->bufferPos;
  282. SkipToEndGroupInternal(state, GPBWireFormatMakeTag(fieldNumber, GPBWireFormatEndGroup));
  283. // This will be after the end group tag.
  284. const uint8_t *end = state->bytes + state->bufferPos;
  285. return [[NSData alloc] initWithBytesNoCopy:(void *)start
  286. length:(NSUInteger)(end - start)
  287. freeWhenDone:NO];
  288. }
  289. size_t GPBCodedInputStreamPushLimit(GPBCodedInputStreamState *state, size_t byteLimit) {
  290. byteLimit += state->bufferPos;
  291. size_t oldLimit = state->currentLimit;
  292. if (byteLimit > oldLimit) {
  293. GPBRaiseStreamError(GPBCodedInputStreamErrorInvalidSubsectionLimit, nil);
  294. }
  295. state->currentLimit = byteLimit;
  296. return oldLimit;
  297. }
  298. void GPBCodedInputStreamPopLimit(GPBCodedInputStreamState *state, size_t oldLimit) {
  299. state->currentLimit = oldLimit;
  300. }
  301. size_t GPBCodedInputStreamBytesUntilLimit(GPBCodedInputStreamState *state) {
  302. return state->currentLimit - state->bufferPos;
  303. }
  304. BOOL GPBCodedInputStreamIsAtEnd(GPBCodedInputStreamState *state) {
  305. return (state->bufferPos == state->bufferSize) || (state->bufferPos == state->currentLimit);
  306. }
  307. void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state, int32_t value) {
  308. if (state->lastTag != value) {
  309. GPBRaiseStreamError(GPBCodedInputStreamErrorInvalidTag, @"Unexpected tag read");
  310. }
  311. }
  312. @implementation GPBCodedInputStream
  313. + (instancetype)streamWithData:(NSData *)data {
  314. return [[[self alloc] initWithData:data] autorelease];
  315. }
  316. - (instancetype)initWithData:(NSData *)data {
  317. if ((self = [super init])) {
  318. #ifdef DEBUG
  319. NSCAssert([self class] == [GPBCodedInputStream class],
  320. @"Subclassing of GPBCodedInputStream is not allowed.");
  321. #endif
  322. buffer_ = [data retain];
  323. state_.bytes = (const uint8_t *)[data bytes];
  324. state_.bufferSize = [data length];
  325. state_.currentLimit = state_.bufferSize;
  326. }
  327. return self;
  328. }
  329. - (void)dealloc {
  330. [buffer_ release];
  331. [super dealloc];
  332. }
  333. // Direct access is use for speed, to avoid even internally declaring things
  334. // read/write, etc. The warning is enabled in the project to ensure code calling
  335. // protos can turn on -Wdirect-ivar-access without issues.
  336. #pragma clang diagnostic push
  337. #pragma clang diagnostic ignored "-Wdirect-ivar-access"
  338. - (int32_t)readTag {
  339. return GPBCodedInputStreamReadTag(&state_);
  340. }
  341. - (void)checkLastTagWas:(int32_t)value {
  342. GPBCodedInputStreamCheckLastTagWas(&state_, value);
  343. }
  344. - (BOOL)skipField:(int32_t)tag {
  345. NSAssert(GPBWireFormatIsValidTag(tag), @"Invalid tag");
  346. switch (GPBWireFormatGetTagWireType(tag)) {
  347. case GPBWireFormatVarint:
  348. GPBCodedInputStreamReadInt32(&state_);
  349. return YES;
  350. case GPBWireFormatFixed64:
  351. SkipRawData(&state_, sizeof(int64_t));
  352. return YES;
  353. case GPBWireFormatLengthDelimited: {
  354. uint64_t size = GPBCodedInputStreamReadUInt64(&state_);
  355. CheckFieldSize(size);
  356. size_t size2 = (size_t)size; // Cast safe on 32bit because of CheckFieldSize() above.
  357. SkipRawData(&state_, size2);
  358. return YES;
  359. }
  360. case GPBWireFormatStartGroup:
  361. [self skipMessage];
  362. GPBCodedInputStreamCheckLastTagWas(
  363. &state_,
  364. GPBWireFormatMakeTag(GPBWireFormatGetTagFieldNumber(tag), GPBWireFormatEndGroup));
  365. return YES;
  366. case GPBWireFormatEndGroup:
  367. return NO;
  368. case GPBWireFormatFixed32:
  369. SkipRawData(&state_, sizeof(int32_t));
  370. return YES;
  371. }
  372. }
  373. - (void)skipMessage {
  374. while (YES) {
  375. int32_t tag = GPBCodedInputStreamReadTag(&state_);
  376. if (tag == 0 || ![self skipField:tag]) {
  377. return;
  378. }
  379. }
  380. }
  381. - (BOOL)isAtEnd {
  382. return GPBCodedInputStreamIsAtEnd(&state_);
  383. }
  384. - (size_t)position {
  385. return state_.bufferPos;
  386. }
  387. - (size_t)pushLimit:(size_t)byteLimit {
  388. return GPBCodedInputStreamPushLimit(&state_, byteLimit);
  389. }
  390. - (void)popLimit:(size_t)oldLimit {
  391. GPBCodedInputStreamPopLimit(&state_, oldLimit);
  392. }
  393. - (size_t)bytesUntilLimit {
  394. return GPBCodedInputStreamBytesUntilLimit(&state_);
  395. }
  396. - (double)readDouble {
  397. return GPBCodedInputStreamReadDouble(&state_);
  398. }
  399. - (float)readFloat {
  400. return GPBCodedInputStreamReadFloat(&state_);
  401. }
  402. - (uint64_t)readUInt64 {
  403. return GPBCodedInputStreamReadUInt64(&state_);
  404. }
  405. - (int64_t)readInt64 {
  406. return GPBCodedInputStreamReadInt64(&state_);
  407. }
  408. - (int32_t)readInt32 {
  409. return GPBCodedInputStreamReadInt32(&state_);
  410. }
  411. - (uint64_t)readFixed64 {
  412. return GPBCodedInputStreamReadFixed64(&state_);
  413. }
  414. - (uint32_t)readFixed32 {
  415. return GPBCodedInputStreamReadFixed32(&state_);
  416. }
  417. - (BOOL)readBool {
  418. return GPBCodedInputStreamReadBool(&state_);
  419. }
  420. - (NSString *)readString {
  421. return [GPBCodedInputStreamReadRetainedString(&state_) autorelease];
  422. }
  423. - (void)readGroup:(int32_t)fieldNumber
  424. message:(GPBMessage *)message
  425. extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry {
  426. CheckRecursionLimit(&state_);
  427. ++state_.recursionDepth;
  428. [message mergeFromCodedInputStream:self
  429. extensionRegistry:extensionRegistry
  430. endingTag:GPBWireFormatMakeTag(fieldNumber, GPBWireFormatEndGroup)];
  431. --state_.recursionDepth;
  432. }
  433. #pragma clang diagnostic push
  434. #pragma clang diagnostic ignored "-Wdeprecated-declarations"
  435. - (void)readUnknownGroup:(int32_t)fieldNumber message:(GPBUnknownFieldSet *)message {
  436. CheckRecursionLimit(&state_);
  437. ++state_.recursionDepth;
  438. [message mergeFromCodedInputStream:self];
  439. GPBCodedInputStreamCheckLastTagWas(&state_,
  440. GPBWireFormatMakeTag(fieldNumber, GPBWireFormatEndGroup));
  441. --state_.recursionDepth;
  442. }
  443. #pragma clang diagnostic pop
  444. - (void)readMessage:(GPBMessage *)message
  445. extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry {
  446. CheckRecursionLimit(&state_);
  447. uint64_t length = GPBCodedInputStreamReadUInt64(&state_);
  448. CheckFieldSize(length);
  449. size_t length2 = (size_t)length; // Cast safe on 32bit because of CheckFieldSize() above.
  450. size_t oldLimit = GPBCodedInputStreamPushLimit(&state_, length2);
  451. ++state_.recursionDepth;
  452. [message mergeFromCodedInputStream:self extensionRegistry:extensionRegistry endingTag:0];
  453. --state_.recursionDepth;
  454. GPBCodedInputStreamPopLimit(&state_, oldLimit);
  455. }
  456. - (void)readMapEntry:(id)mapDictionary
  457. extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry
  458. field:(GPBFieldDescriptor *)field
  459. parentMessage:(GPBMessage *)parentMessage {
  460. CheckRecursionLimit(&state_);
  461. uint64_t length = GPBCodedInputStreamReadUInt64(&state_);
  462. CheckFieldSize(length);
  463. size_t length2 = (size_t)length; // Cast safe on 32bit because of CheckFieldSize() above.
  464. size_t oldLimit = GPBCodedInputStreamPushLimit(&state_, length2);
  465. ++state_.recursionDepth;
  466. GPBDictionaryReadEntry(mapDictionary, self, extensionRegistry, field, parentMessage);
  467. GPBCodedInputStreamCheckLastTagWas(&state_, 0);
  468. --state_.recursionDepth;
  469. GPBCodedInputStreamPopLimit(&state_, oldLimit);
  470. }
  471. - (NSData *)readBytes {
  472. return [GPBCodedInputStreamReadRetainedBytes(&state_) autorelease];
  473. }
  474. - (uint32_t)readUInt32 {
  475. return GPBCodedInputStreamReadUInt32(&state_);
  476. }
  477. - (int32_t)readEnum {
  478. return GPBCodedInputStreamReadEnum(&state_);
  479. }
  480. - (int32_t)readSFixed32 {
  481. return GPBCodedInputStreamReadSFixed32(&state_);
  482. }
  483. - (int64_t)readSFixed64 {
  484. return GPBCodedInputStreamReadSFixed64(&state_);
  485. }
  486. - (int32_t)readSInt32 {
  487. return GPBCodedInputStreamReadSInt32(&state_);
  488. }
  489. - (int64_t)readSInt64 {
  490. return GPBCodedInputStreamReadSInt64(&state_);
  491. }
  492. #pragma clang diagnostic pop
  493. @end