Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(616)

Side by Side Diff: third_party/protobuf/objectivec/GPBCodedInputStream.m

Issue 1983203003: Update third_party/protobuf to protobuf-v3.0.0-beta-3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: owners Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Protocol Buffers - Google's data interchange format 1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved. 2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/ 3 // https://developers.google.com/protocol-buffers/
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // * Redistributions of source code must retain the above copyright 9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer. 10 // notice, this list of conditions and the following disclaimer.
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 GPBCodedInputStreamState *state) { 212 GPBCodedInputStreamState *state) {
213 int32_t size = ReadRawVarint32(state); 213 int32_t size = ReadRawVarint32(state);
214 NSString *result; 214 NSString *result;
215 if (size == 0) { 215 if (size == 0) {
216 result = @""; 216 result = @"";
217 } else { 217 } else {
218 CheckSize(state, size); 218 CheckSize(state, size);
219 result = [[NSString alloc] initWithBytes:&state->bytes[state->bufferPos] 219 result = [[NSString alloc] initWithBytes:&state->bytes[state->bufferPos]
220 length:size 220 length:size
221 encoding:NSUTF8StringEncoding]; 221 encoding:NSUTF8StringEncoding];
222 state->bufferPos += size;
222 if (!result) { 223 if (!result) {
223 result = @"";
224 #ifdef DEBUG 224 #ifdef DEBUG
225 // https://developers.google.com/protocol-buffers/docs/proto#scalar 225 // https://developers.google.com/protocol-buffers/docs/proto#scalar
226 NSLog(@"UTF8 failure, is some field type 'string' when it should be " 226 NSLog(@"UTF-8 failure, is some field type 'string' when it should be "
227 @"'bytes'?"); 227 @"'bytes'?");
228 #endif 228 #endif
229 [NSException raise:NSParseErrorException
230 format:@"Invalid UTF-8 for a 'string'"];
229 } 231 }
230 state->bufferPos += size;
231 } 232 }
232 return result; 233 return result;
233 } 234 }
234 235
235 NSData *GPBCodedInputStreamReadRetainedBytes(GPBCodedInputStreamState *state) { 236 NSData *GPBCodedInputStreamReadRetainedBytes(GPBCodedInputStreamState *state) {
236 int32_t size = ReadRawVarint32(state); 237 int32_t size = ReadRawVarint32(state);
237 if (size < 0) return nil; 238 if (size < 0) return nil;
238 CheckSize(state, size); 239 CheckSize(state, size);
239 NSData *result = [[NSData alloc] initWithBytes:state->bytes + state->bufferPos 240 NSData *result = [[NSData alloc] initWithBytes:state->bytes + state->bufferPos
240 length:size]; 241 length:size];
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 353
353 - (void)skipMessage { 354 - (void)skipMessage {
354 while (YES) { 355 while (YES) {
355 int32_t tag = GPBCodedInputStreamReadTag(&state_); 356 int32_t tag = GPBCodedInputStreamReadTag(&state_);
356 if (tag == 0 || ![self skipField:tag]) { 357 if (tag == 0 || ![self skipField:tag]) {
357 return; 358 return;
358 } 359 }
359 } 360 }
360 } 361 }
361 362
363 - (BOOL)isAtEnd {
364 return GPBCodedInputStreamIsAtEnd(&state_);
365 }
366
367 - (size_t)position {
368 return state_.bufferPos;
369 }
370
362 - (double)readDouble { 371 - (double)readDouble {
363 return GPBCodedInputStreamReadDouble(&state_); 372 return GPBCodedInputStreamReadDouble(&state_);
364 } 373 }
365 374
366 - (float)readFloat { 375 - (float)readFloat {
367 return GPBCodedInputStreamReadFloat(&state_); 376 return GPBCodedInputStreamReadFloat(&state_);
368 } 377 }
369 378
370 - (uint64_t)readUInt64 { 379 - (uint64_t)readUInt64 {
371 return GPBCodedInputStreamReadUInt64(&state_); 380 return GPBCodedInputStreamReadUInt64(&state_);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 490
482 - (int32_t)readSInt32 { 491 - (int32_t)readSInt32 {
483 return GPBCodedInputStreamReadSInt32(&state_); 492 return GPBCodedInputStreamReadSInt32(&state_);
484 } 493 }
485 494
486 - (int64_t)readSInt64 { 495 - (int64_t)readSInt64 {
487 return GPBCodedInputStreamReadSInt64(&state_); 496 return GPBCodedInputStreamReadSInt64(&state_);
488 } 497 }
489 498
490 @end 499 @end
OLDNEW
« no previous file with comments | « third_party/protobuf/objectivec/GPBCodedInputStream.h ('k') | third_party/protobuf/objectivec/GPBCodedOutputStream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698