diff options
28 files changed, 257 insertions, 137 deletions
diff --git a/objectivec/GPBMessage.h b/objectivec/GPBMessage.h index d4c2fccf..332393ed 100644 --- a/objectivec/GPBMessage.h +++ b/objectivec/GPBMessage.h @@ -127,7 +127,7 @@ CF_EXTERN_C_END // Same as -[data], except a delimiter is added to the start of the data // indicating the size of the message data that follows. -- (nullable NSData *)delimitedData; +- (NSData *)delimitedData; // Returns the size of the object if it were serialized. // This is not a cached value. If you are following a pattern like this: diff --git a/objectivec/GPBMessage.m b/objectivec/GPBMessage.m index c655edd3..d9080c3f 100644 --- a/objectivec/GPBMessage.m +++ b/objectivec/GPBMessage.m @@ -55,10 +55,15 @@ NSString *const GPBExceptionMessageKey = static NSString *const kGPBDataCoderKey = @"GPBData"; #ifndef _GPBCompileAssert -#define _GPBCompileAssertSymbolInner(line, msg) _GPBCompileAssert ## line ## __ ## msg -#define _GPBCompileAssertSymbol(line, msg) _GPBCompileAssertSymbolInner(line, msg) -#define _GPBCompileAssert(test, msg) \ - typedef char _GPBCompileAssertSymbol(__LINE__, msg) [ ((test) ? 1 : -1) ] + #if __has_feature(c_static_assert) || __has_extension(c_static_assert) + #define _GPBCompileAssert(test, msg) _Static_assert((test), #msg) + #else + // Pre-Xcode 7 support. + #define _GPBCompileAssertSymbolInner(line, msg) _GPBCompileAssert ## line ## __ ## msg + #define _GPBCompileAssertSymbol(line, msg) _GPBCompileAssertSymbolInner(line, msg) + #define _GPBCompileAssert(test, msg) \ + typedef char _GPBCompileAssertSymbol(__LINE__, msg) [ ((test) ? 1 : -1) ] + #endif // __has_feature(c_static_assert) || __has_extension(c_static_assert) #endif // _GPBCompileAssert // @@ -1212,7 +1217,8 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) { NSLog(@"%@: Internal exception while building message delimitedData: %@", [self class], exception); #endif - data = nil; + // If it happens, truncate. + data.length = 0; } [stream release]; return data; @@ -1791,7 +1797,12 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) { extensionMap_ = [[NSMutableDictionary alloc] init]; } - [extensionMap_ setObject:value forKey:extension]; + // This pointless cast is for CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION. + // Without it, the compiler complains we're passing an id nullable when + // setObject:forKey: requires a id nonnull for the value. The check for + // !value at the start of the method ensures it isn't nil, but the check + // isn't smart enough to realize that. + [extensionMap_ setObject:(id)value forKey:extension]; GPBExtensionDescriptor *descriptor = extension; diff --git a/objectivec/GPBUtilities.h b/objectivec/GPBUtilities.h index 1301b436..5b55104b 100644 --- a/objectivec/GPBUtilities.h +++ b/objectivec/GPBUtilities.h @@ -44,7 +44,7 @@ NS_ASSUME_NONNULL_BEGIN // most likely won't exactly match the original .proto file. NSString *GPBTextFormatForMessage(GPBMessage *message, NSString * __nullable lineIndent); -NSString *GPBTextFormatForUnknownFieldSet(GPBUnknownFieldSet *unknownSet, +NSString *GPBTextFormatForUnknownFieldSet(GPBUnknownFieldSet * __nullable unknownSet, NSString * __nullable lineIndent); // diff --git a/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj b/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj index 08d0b7ef..b17a4f4a 100644 --- a/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj +++ b/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj @@ -787,6 +787,7 @@ CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; CLANG_STATIC_ANALYZER_MODE = deep; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION = YES; CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES; CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; @@ -831,6 +832,7 @@ CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; CLANG_STATIC_ANALYZER_MODE = deep; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION = YES; CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES; CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; diff --git a/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj b/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj index 14e51037..e0a45ef6 100644 --- a/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj +++ b/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj @@ -949,6 +949,7 @@ CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; CLANG_STATIC_ANALYZER_MODE = deep; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION = YES; CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES; CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; @@ -994,6 +995,7 @@ CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; CLANG_STATIC_ANALYZER_MODE = deep; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION = YES; CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES; CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; diff --git a/objectivec/Tests/GPBCodedInputStreamTests.m b/objectivec/Tests/GPBCodedInputStreamTests.m index 579fe65c..7c3c006b 100644 --- a/objectivec/Tests/GPBCodedInputStreamTests.m +++ b/objectivec/Tests/GPBCodedInputStreamTests.m @@ -225,8 +225,10 @@ // Serialize and parse it. Make sure to parse from an InputStream, not // directly from a ByteString, so that CodedInputStream uses buffered // reading. + NSData *messageData = message.data; + XCTAssertNotNil(messageData); GPBCodedInputStream* stream = - [GPBCodedInputStream streamWithData:message.data]; + [GPBCodedInputStream streamWithData:messageData]; TestAllTypes* message2 = [TestAllTypes parseFromCodedInputStream:stream extensionRegistry:nil error:NULL]; diff --git a/objectivec/Tests/GPBMessageTests+Serialization.m b/objectivec/Tests/GPBMessageTests+Serialization.m index 4dcca7a3..0d811a96 100644 --- a/objectivec/Tests/GPBMessageTests+Serialization.m +++ b/objectivec/Tests/GPBMessageTests+Serialization.m @@ -121,8 +121,9 @@ static NSData *DataFromCStr(const char *str) { fooWithExtras.enumValue = DropUnknownsFooWithExtraFields_NestedEnum_Baz; fooWithExtras.extraInt32Value = 2; - DropUnknownsFoo *foo = - [DropUnknownsFoo parseFromData:[fooWithExtras data] error:NULL]; + NSData *data = [fooWithExtras data]; + XCTAssertNotNil(data); + DropUnknownsFoo *foo = [DropUnknownsFoo parseFromData:data error:NULL]; XCTAssertEqual(foo.int32Value, 1); XCTAssertEqual(foo.enumValue, DropUnknownsFoo_NestedEnum_Baz); @@ -130,8 +131,9 @@ static NSData *DataFromCStr(const char *str) { XCTAssertEqual([foo.unknownFields countOfFields], 0U); [fooWithExtras release]; + data = [foo data]; fooWithExtras = - [DropUnknownsFooWithExtraFields parseFromData:[foo data] error:NULL]; + [DropUnknownsFooWithExtraFields parseFromData:data error:NULL]; XCTAssertEqual(fooWithExtras.int32Value, 1); XCTAssertEqual(fooWithExtras.enumValue, DropUnknownsFooWithExtraFields_NestedEnum_Baz); @@ -149,7 +151,9 @@ static NSData *DataFromCStr(const char *str) { rawValue:Message3_Enum_Extra3]; orig.oneofEnum = Message3_Enum_Extra3; - Message2 *msg = [[Message2 alloc] initWithData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message2 *msg = [[Message2 alloc] initWithData:data error:NULL]; // None of the fields should be set. @@ -201,8 +205,10 @@ static NSData *DataFromCStr(const char *str) { // Everything should be there via raw values. + NSData *data = [orig data]; + XCTAssertNotNil(data); UnknownEnumsMyMessage *msg = - [UnknownEnumsMyMessage parseFromData:[orig data] error:NULL]; + [UnknownEnumsMyMessage parseFromData:data error:NULL]; XCTAssertEqual(msg.e, UnknownEnumsMyEnum_GPBUnrecognizedEnumeratorValue); XCTAssertEqual(UnknownEnumsMyMessage_E_RawValue(msg), @@ -224,7 +230,8 @@ static NSData *DataFromCStr(const char *str) { // Everything should go out and come back. - orig = [UnknownEnumsMyMessagePlusExtra parseFromData:[msg data] error:NULL]; + data = [msg data]; + orig = [UnknownEnumsMyMessagePlusExtra parseFromData:data error:NULL]; XCTAssertEqual(orig.e, UnknownEnumsMyEnumPlusExtra_EExtra); XCTAssertEqual(orig.repeatedEArray.count, 1U); @@ -243,7 +250,9 @@ static NSData *DataFromCStr(const char *str) { //% MESSAGE *orig = [[MESSAGE alloc] init]; //% orig.oneof##FIELD = VALUE; //% XCTAssertEqual(orig.oOneOfCase, MESSAGE##_O_OneOfCase_Oneof##FIELD); -//% MESSAGE *msg = [MESSAGE parseFromData:[orig data] error:NULL]; +//% NSData *data = [orig data]; +//% XCTAssertNotNil(data); +//% MESSAGE *msg = [MESSAGE parseFromData:data error:NULL]; //% XCTAssertEqual(msg.oOneOfCase, MESSAGE##_O_OneOfCase_Oneof##FIELD); //% XCTAssertEqual##EQ_SUFFIX(msg.oneof##FIELD, VALUE); //% [orig release]; @@ -311,7 +320,9 @@ static NSData *DataFromCStr(const char *str) { Message2 *orig = [[Message2 alloc] init]; orig.oneofInt32 = 1; XCTAssertEqual(orig.oOneOfCase, Message2_O_OneOfCase_OneofInt32); - Message2 *msg = [Message2 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message2 *msg = [Message2 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_OneofInt32); XCTAssertEqual(msg.oneofInt32, 1); [orig release]; @@ -321,7 +332,9 @@ static NSData *DataFromCStr(const char *str) { Message2 *orig = [[Message2 alloc] init]; orig.oneofInt64 = 2; XCTAssertEqual(orig.oOneOfCase, Message2_O_OneOfCase_OneofInt64); - Message2 *msg = [Message2 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message2 *msg = [Message2 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_OneofInt64); XCTAssertEqual(msg.oneofInt64, 2); [orig release]; @@ -331,7 +344,9 @@ static NSData *DataFromCStr(const char *str) { Message2 *orig = [[Message2 alloc] init]; orig.oneofUint32 = 3U; XCTAssertEqual(orig.oOneOfCase, Message2_O_OneOfCase_OneofUint32); - Message2 *msg = [Message2 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message2 *msg = [Message2 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_OneofUint32); XCTAssertEqual(msg.oneofUint32, 3U); [orig release]; @@ -341,7 +356,9 @@ static NSData *DataFromCStr(const char *str) { Message2 *orig = [[Message2 alloc] init]; orig.oneofUint64 = 4U; XCTAssertEqual(orig.oOneOfCase, Message2_O_OneOfCase_OneofUint64); - Message2 *msg = [Message2 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message2 *msg = [Message2 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_OneofUint64); XCTAssertEqual(msg.oneofUint64, 4U); [orig release]; @@ -351,7 +368,9 @@ static NSData *DataFromCStr(const char *str) { Message2 *orig = [[Message2 alloc] init]; orig.oneofSint32 = 5; XCTAssertEqual(orig.oOneOfCase, Message2_O_OneOfCase_OneofSint32); - Message2 *msg = [Message2 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message2 *msg = [Message2 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_OneofSint32); XCTAssertEqual(msg.oneofSint32, 5); [orig release]; @@ -361,7 +380,9 @@ static NSData *DataFromCStr(const char *str) { Message2 *orig = [[Message2 alloc] init]; orig.oneofSint64 = 6; XCTAssertEqual(orig.oOneOfCase, Message2_O_OneOfCase_OneofSint64); - Message2 *msg = [Message2 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message2 *msg = [Message2 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_OneofSint64); XCTAssertEqual(msg.oneofSint64, 6); [orig release]; @@ -371,7 +392,9 @@ static NSData *DataFromCStr(const char *str) { Message2 *orig = [[Message2 alloc] init]; orig.oneofFixed32 = 7U; XCTAssertEqual(orig.oOneOfCase, Message2_O_OneOfCase_OneofFixed32); - Message2 *msg = [Message2 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message2 *msg = [Message2 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_OneofFixed32); XCTAssertEqual(msg.oneofFixed32, 7U); [orig release]; @@ -381,7 +404,9 @@ static NSData *DataFromCStr(const char *str) { Message2 *orig = [[Message2 alloc] init]; orig.oneofFixed64 = 8U; XCTAssertEqual(orig.oOneOfCase, Message2_O_OneOfCase_OneofFixed64); - Message2 *msg = [Message2 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message2 *msg = [Message2 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_OneofFixed64); XCTAssertEqual(msg.oneofFixed64, 8U); [orig release]; @@ -391,7 +416,9 @@ static NSData *DataFromCStr(const char *str) { Message2 *orig = [[Message2 alloc] init]; orig.oneofSfixed32 = 9; XCTAssertEqual(orig.oOneOfCase, Message2_O_OneOfCase_OneofSfixed32); - Message2 *msg = [Message2 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message2 *msg = [Message2 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_OneofSfixed32); XCTAssertEqual(msg.oneofSfixed32, 9); [orig release]; @@ -401,7 +428,9 @@ static NSData *DataFromCStr(const char *str) { Message2 *orig = [[Message2 alloc] init]; orig.oneofSfixed64 = 10; XCTAssertEqual(orig.oOneOfCase, Message2_O_OneOfCase_OneofSfixed64); - Message2 *msg = [Message2 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message2 *msg = [Message2 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_OneofSfixed64); XCTAssertEqual(msg.oneofSfixed64, 10); [orig release]; @@ -411,7 +440,9 @@ static NSData *DataFromCStr(const char *str) { Message2 *orig = [[Message2 alloc] init]; orig.oneofFloat = 11.0f; XCTAssertEqual(orig.oOneOfCase, Message2_O_OneOfCase_OneofFloat); - Message2 *msg = [Message2 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message2 *msg = [Message2 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_OneofFloat); XCTAssertEqual(msg.oneofFloat, 11.0f); [orig release]; @@ -421,7 +452,9 @@ static NSData *DataFromCStr(const char *str) { Message2 *orig = [[Message2 alloc] init]; orig.oneofDouble = 12.0; XCTAssertEqual(orig.oOneOfCase, Message2_O_OneOfCase_OneofDouble); - Message2 *msg = [Message2 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message2 *msg = [Message2 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_OneofDouble); XCTAssertEqual(msg.oneofDouble, 12.0); [orig release]; @@ -431,7 +464,9 @@ static NSData *DataFromCStr(const char *str) { Message2 *orig = [[Message2 alloc] init]; orig.oneofBool = NO; XCTAssertEqual(orig.oOneOfCase, Message2_O_OneOfCase_OneofBool); - Message2 *msg = [Message2 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message2 *msg = [Message2 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_OneofBool); XCTAssertEqual(msg.oneofBool, NO); [orig release]; @@ -441,7 +476,9 @@ static NSData *DataFromCStr(const char *str) { Message2 *orig = [[Message2 alloc] init]; orig.oneofString = @"foo"; XCTAssertEqual(orig.oOneOfCase, Message2_O_OneOfCase_OneofString); - Message2 *msg = [Message2 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message2 *msg = [Message2 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_OneofString); XCTAssertEqualObjects(msg.oneofString, @"foo"); [orig release]; @@ -451,7 +488,9 @@ static NSData *DataFromCStr(const char *str) { Message2 *orig = [[Message2 alloc] init]; orig.oneofBytes = [@"bar" dataUsingEncoding:NSUTF8StringEncoding]; XCTAssertEqual(orig.oOneOfCase, Message2_O_OneOfCase_OneofBytes); - Message2 *msg = [Message2 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message2 *msg = [Message2 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_OneofBytes); XCTAssertEqualObjects(msg.oneofBytes, [@"bar" dataUsingEncoding:NSUTF8StringEncoding]); [orig release]; @@ -461,7 +500,9 @@ static NSData *DataFromCStr(const char *str) { Message2 *orig = [[Message2 alloc] init]; orig.oneofGroup = group; XCTAssertEqual(orig.oOneOfCase, Message2_O_OneOfCase_OneofGroup); - Message2 *msg = [Message2 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message2 *msg = [Message2 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_OneofGroup); XCTAssertEqualObjects(msg.oneofGroup, group); [orig release]; @@ -471,7 +512,9 @@ static NSData *DataFromCStr(const char *str) { Message2 *orig = [[Message2 alloc] init]; orig.oneofMessage = subMessage; XCTAssertEqual(orig.oOneOfCase, Message2_O_OneOfCase_OneofMessage); - Message2 *msg = [Message2 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message2 *msg = [Message2 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_OneofMessage); XCTAssertEqualObjects(msg.oneofMessage, subMessage); [orig release]; @@ -481,7 +524,9 @@ static NSData *DataFromCStr(const char *str) { Message2 *orig = [[Message2 alloc] init]; orig.oneofEnum = Message2_Enum_Bar; XCTAssertEqual(orig.oOneOfCase, Message2_O_OneOfCase_OneofEnum); - Message2 *msg = [Message2 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message2 *msg = [Message2 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_OneofEnum); XCTAssertEqual(msg.oneofEnum, Message2_Enum_Bar); [orig release]; @@ -504,7 +549,9 @@ static NSData *DataFromCStr(const char *str) { Message3 *orig = [[Message3 alloc] init]; orig.oneofInt32 = 1; XCTAssertEqual(orig.oOneOfCase, Message3_O_OneOfCase_OneofInt32); - Message3 *msg = [Message3 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message3 *msg = [Message3 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_OneofInt32); XCTAssertEqual(msg.oneofInt32, 1); [orig release]; @@ -514,7 +561,9 @@ static NSData *DataFromCStr(const char *str) { Message3 *orig = [[Message3 alloc] init]; orig.oneofInt64 = 2; XCTAssertEqual(orig.oOneOfCase, Message3_O_OneOfCase_OneofInt64); - Message3 *msg = [Message3 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message3 *msg = [Message3 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_OneofInt64); XCTAssertEqual(msg.oneofInt64, 2); [orig release]; @@ -524,7 +573,9 @@ static NSData *DataFromCStr(const char *str) { Message3 *orig = [[Message3 alloc] init]; orig.oneofUint32 = 3U; XCTAssertEqual(orig.oOneOfCase, Message3_O_OneOfCase_OneofUint32); - Message3 *msg = [Message3 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message3 *msg = [Message3 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_OneofUint32); XCTAssertEqual(msg.oneofUint32, 3U); [orig release]; @@ -534,7 +585,9 @@ static NSData *DataFromCStr(const char *str) { Message3 *orig = [[Message3 alloc] init]; orig.oneofUint64 = 4U; XCTAssertEqual(orig.oOneOfCase, Message3_O_OneOfCase_OneofUint64); - Message3 *msg = [Message3 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message3 *msg = [Message3 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_OneofUint64); XCTAssertEqual(msg.oneofUint64, 4U); [orig release]; @@ -544,7 +597,9 @@ static NSData *DataFromCStr(const char *str) { Message3 *orig = [[Message3 alloc] init]; orig.oneofSint32 = 5; XCTAssertEqual(orig.oOneOfCase, Message3_O_OneOfCase_OneofSint32); - Message3 *msg = [Message3 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message3 *msg = [Message3 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_OneofSint32); XCTAssertEqual(msg.oneofSint32, 5); [orig release]; @@ -554,7 +609,9 @@ static NSData *DataFromCStr(const char *str) { Message3 *orig = [[Message3 alloc] init]; orig.oneofSint64 = 6; XCTAssertEqual(orig.oOneOfCase, Message3_O_OneOfCase_OneofSint64); - Message3 *msg = [Message3 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message3 *msg = [Message3 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_OneofSint64); XCTAssertEqual(msg.oneofSint64, 6); [orig release]; @@ -564,7 +621,9 @@ static NSData *DataFromCStr(const char *str) { Message3 *orig = [[Message3 alloc] init]; orig.oneofFixed32 = 7U; XCTAssertEqual(orig.oOneOfCase, Message3_O_OneOfCase_OneofFixed32); - Message3 *msg = [Message3 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message3 *msg = [Message3 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_OneofFixed32); XCTAssertEqual(msg.oneofFixed32, 7U); [orig release]; @@ -574,7 +633,9 @@ static NSData *DataFromCStr(const char *str) { Message3 *orig = [[Message3 alloc] init]; orig.oneofFixed64 = 8U; XCTAssertEqual(orig.oOneOfCase, Message3_O_OneOfCase_OneofFixed64); - Message3 *msg = [Message3 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message3 *msg = [Message3 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_OneofFixed64); XCTAssertEqual(msg.oneofFixed64, 8U); [orig release]; @@ -584,7 +645,9 @@ static NSData *DataFromCStr(const char *str) { Message3 *orig = [[Message3 alloc] init]; orig.oneofSfixed32 = 9; XCTAssertEqual(orig.oOneOfCase, Message3_O_OneOfCase_OneofSfixed32); - Message3 *msg = [Message3 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message3 *msg = [Message3 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_OneofSfixed32); XCTAssertEqual(msg.oneofSfixed32, 9); [orig release]; @@ -594,7 +657,9 @@ static NSData *DataFromCStr(const char *str) { Message3 *orig = [[Message3 alloc] init]; orig.oneofSfixed64 = 10; XCTAssertEqual(orig.oOneOfCase, Message3_O_OneOfCase_OneofSfixed64); - Message3 *msg = [Message3 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message3 *msg = [Message3 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_OneofSfixed64); XCTAssertEqual(msg.oneofSfixed64, 10); [orig release]; @@ -604,7 +669,9 @@ static NSData *DataFromCStr(const char *str) { Message3 *orig = [[Message3 alloc] init]; orig.oneofFloat = 11.0f; XCTAssertEqual(orig.oOneOfCase, Message3_O_OneOfCase_OneofFloat); - Message3 *msg = [Message3 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message3 *msg = [Message3 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_OneofFloat); XCTAssertEqual(msg.oneofFloat, 11.0f); [orig release]; @@ -614,7 +681,9 @@ static NSData *DataFromCStr(const char *str) { Message3 *orig = [[Message3 alloc] init]; orig.oneofDouble = 12.0; XCTAssertEqual(orig.oOneOfCase, Message3_O_OneOfCase_OneofDouble); - Message3 *msg = [Message3 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message3 *msg = [Message3 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_OneofDouble); XCTAssertEqual(msg.oneofDouble, 12.0); [orig release]; @@ -624,7 +693,9 @@ static NSData *DataFromCStr(const char *str) { Message3 *orig = [[Message3 alloc] init]; orig.oneofBool = YES; XCTAssertEqual(orig.oOneOfCase, Message3_O_OneOfCase_OneofBool); - Message3 *msg = [Message3 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message3 *msg = [Message3 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_OneofBool); XCTAssertEqual(msg.oneofBool, YES); [orig release]; @@ -634,7 +705,9 @@ static NSData *DataFromCStr(const char *str) { Message3 *orig = [[Message3 alloc] init]; orig.oneofString = @"foo"; XCTAssertEqual(orig.oOneOfCase, Message3_O_OneOfCase_OneofString); - Message3 *msg = [Message3 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message3 *msg = [Message3 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_OneofString); XCTAssertEqualObjects(msg.oneofString, @"foo"); [orig release]; @@ -644,7 +717,9 @@ static NSData *DataFromCStr(const char *str) { Message3 *orig = [[Message3 alloc] init]; orig.oneofBytes = [@"bar" dataUsingEncoding:NSUTF8StringEncoding]; XCTAssertEqual(orig.oOneOfCase, Message3_O_OneOfCase_OneofBytes); - Message3 *msg = [Message3 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message3 *msg = [Message3 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_OneofBytes); XCTAssertEqualObjects(msg.oneofBytes, [@"bar" dataUsingEncoding:NSUTF8StringEncoding]); [orig release]; @@ -656,7 +731,9 @@ static NSData *DataFromCStr(const char *str) { Message3 *orig = [[Message3 alloc] init]; orig.oneofMessage = subMessage; XCTAssertEqual(orig.oOneOfCase, Message3_O_OneOfCase_OneofMessage); - Message3 *msg = [Message3 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message3 *msg = [Message3 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_OneofMessage); XCTAssertEqualObjects(msg.oneofMessage, subMessage); [orig release]; @@ -666,7 +743,9 @@ static NSData *DataFromCStr(const char *str) { Message3 *orig = [[Message3 alloc] init]; orig.oneofEnum = Message2_Enum_Bar; XCTAssertEqual(orig.oOneOfCase, Message3_O_OneOfCase_OneofEnum); - Message3 *msg = [Message3 parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + Message3 *msg = [Message3 parseFromData:data error:NULL]; XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_OneofEnum); XCTAssertEqual(msg.oneofEnum, Message2_Enum_Bar); [orig release]; @@ -927,15 +1006,18 @@ static NSData *DataFromCStr(const char *str) { [orig.unknownMapField setValue:Proto2MapEnumPlusExtra_EProto2MapEnumExtra forKey:0]; - TestEnumMap *msg1 = [TestEnumMap parseFromData:[orig data] error:NULL]; + NSData *data = [orig data]; + XCTAssertNotNil(data); + TestEnumMap *msg1 = [TestEnumMap parseFromData:data error:NULL]; XCTAssertEqual(msg1.knownMapField.count, 1U); int32_t val = -1; XCTAssertTrue([msg1.knownMapField valueForKey:0 value:&val]); XCTAssertEqual(val, Proto2MapEnum_Proto2MapEnumFoo); XCTAssertEqual(msg1.unknownFields.countOfFields, 1U); + data = [msg1 data]; TestEnumMapPlusExtra *msg2 = - [TestEnumMapPlusExtra parseFromData:[msg1 data] error:NULL]; + [TestEnumMapPlusExtra parseFromData:data error:NULL]; val = -1; XCTAssertEqual(msg2.knownMapField.count, 1U); XCTAssertTrue([msg2.knownMapField valueForKey:0 value:&val]); @@ -1006,6 +1088,7 @@ static NSData *DataFromCStr(const char *str) { [msg.mapInt32Message setObject:val4 forKey:2035]; NSData *data = [msg data]; + XCTAssertNotNil(data); Message2 *msg2 = [[Message2 alloc] initWithData:data error:NULL]; XCTAssertNotEqual(msg2, msg); // Pointer comparison diff --git a/objectivec/Tests/GPBMessageTests.m b/objectivec/Tests/GPBMessageTests.m index cd0de8fc..f79b8128 100644 --- a/objectivec/Tests/GPBMessageTests.m +++ b/objectivec/Tests/GPBMessageTests.m @@ -195,7 +195,9 @@ // Test merging from data. result = [self mergeExtensionsDestination]; - [result mergeFromData:[[self mergeExtensionsSource] data] + NSData *data = [[self mergeExtensionsSource] data]; + XCTAssertNotNil(data); + [result mergeFromData:data extensionRegistry:[UnittestRoot extensionRegistry]]; resultData = [result data]; XCTAssertEqualObjects(resultData, mergeResultData); @@ -1884,7 +1886,9 @@ XCTAssertEqual(msg.bar, EnumTestMsg_MyEnum_One); XCTAssertEqual(msg.baz, EnumTestMsg_MyEnum_NegOne); // Bounce to wire and back. - EnumTestMsg *msgPrime = [EnumTestMsg parseFromData:[msg data] error:NULL]; + NSData *data = [msg data]; + XCTAssertNotNil(data); + EnumTestMsg *msgPrime = [EnumTestMsg parseFromData:data error:NULL]; XCTAssertEqualObjects(msgPrime, msg); XCTAssertEqual(msgPrime.foo, EnumTestMsg_MyEnum_Zero); XCTAssertEqual(msgPrime.bar, EnumTestMsg_MyEnum_One); @@ -1896,7 +1900,9 @@ XCTAssertEqual(msg.bar, EnumTestMsg_MyEnum_Two); XCTAssertEqual(msg.baz, EnumTestMsg_MyEnum_NegTwo); // Bounce to wire and back. - msgPrime = [EnumTestMsg parseFromData:[msg data] error:NULL]; + data = [msg data]; + XCTAssertNotNil(data); + msgPrime = [EnumTestMsg parseFromData:data error:NULL]; XCTAssertEqualObjects(msgPrime, msg); XCTAssertEqual(msgPrime.foo, EnumTestMsg_MyEnum_Zero); XCTAssertEqual(msgPrime.bar, EnumTestMsg_MyEnum_Two); @@ -1917,7 +1923,9 @@ XCTAssertEqual([msg.mumbleArray valueAtIndex:3], EnumTestMsg_MyEnum_NegOne); XCTAssertEqual([msg.mumbleArray valueAtIndex:4], EnumTestMsg_MyEnum_NegTwo); // Bounce to wire and back. - msgPrime = [EnumTestMsg parseFromData:[msg data] error:NULL]; + data = [msg data]; + XCTAssertNotNil(data); + msgPrime = [EnumTestMsg parseFromData:data error:NULL]; XCTAssertEqualObjects(msgPrime, msg); XCTAssertEqual([msgPrime.mumbleArray valueAtIndex:0], EnumTestMsg_MyEnum_Zero); diff --git a/src/google/protobuf/any.pb.cc b/src/google/protobuf/any.pb.cc index cbb5d233..321fd315 100644 --- a/src/google/protobuf/any.pb.cc +++ b/src/google/protobuf/any.pb.cc @@ -2,7 +2,7 @@ // source: google/protobuf/any.proto #define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include "google/protobuf/any.pb.h" +#include <google/protobuf/any.pb.h> #include <algorithm> @@ -119,10 +119,10 @@ bool Any::UnpackTo(::google::protobuf::Message* message) const { return _any_metadata_.UnpackTo(message); } -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Any::kTypeUrlFieldNumber; const int Any::kValueFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 Any::Any() : ::google::protobuf::Message(), _internal_metadata_(NULL), _any_metadata_(&type_url_, &value_) { diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index c324c4af..97982ecf 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -27,7 +27,7 @@ #include <google/protobuf/repeated_field.h> #include <google/protobuf/extension_set.h> #include <google/protobuf/unknown_field_set.h> -#include "google/protobuf/any.h" +#include <google/protobuf/any.h> // @@protoc_insertion_point(includes) namespace google { diff --git a/src/google/protobuf/api.pb.cc b/src/google/protobuf/api.pb.cc index 0a2c4ec0..ed90702c 100644 --- a/src/google/protobuf/api.pb.cc +++ b/src/google/protobuf/api.pb.cc @@ -2,7 +2,7 @@ // source: google/protobuf/api.proto #define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include "google/protobuf/api.pb.h" +#include <google/protobuf/api.pb.h> #include <algorithm> @@ -186,7 +186,7 @@ static void MergeFromFail(int line) { // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Api::kNameFieldNumber; const int Api::kMethodsFieldNumber; const int Api::kOptionsFieldNumber; @@ -194,7 +194,7 @@ const int Api::kVersionFieldNumber; const int Api::kSourceContextFieldNumber; const int Api::kMixinsFieldNumber; const int Api::kSyntaxFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 Api::Api() : ::google::protobuf::Message(), _internal_metadata_(NULL) { @@ -904,7 +904,7 @@ void Api::clear_syntax() { // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Method::kNameFieldNumber; const int Method::kRequestTypeUrlFieldNumber; const int Method::kRequestStreamingFieldNumber; @@ -912,7 +912,7 @@ const int Method::kResponseTypeUrlFieldNumber; const int Method::kResponseStreamingFieldNumber; const int Method::kOptionsFieldNumber; const int Method::kSyntaxFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 Method::Method() : ::google::protobuf::Message(), _internal_metadata_(NULL) { @@ -1608,10 +1608,10 @@ void Method::clear_syntax() { // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Mixin::kNameFieldNumber; const int Mixin::kRootFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 Mixin::Mixin() : ::google::protobuf::Message(), _internal_metadata_(NULL) { diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h index 3c5a6f31..e1dca4e4 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -27,8 +27,8 @@ #include <google/protobuf/repeated_field.h> #include <google/protobuf/extension_set.h> #include <google/protobuf/unknown_field_set.h> -#include "google/protobuf/source_context.pb.h" -#include "google/protobuf/type.pb.h" +#include <google/protobuf/source_context.pb.h> +#include <google/protobuf/type.pb.h> // @@protoc_insertion_point(includes) namespace google { diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc index 4906985d..9aa41534 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.cc +++ b/src/google/protobuf/compiler/cpp/cpp_file.cc @@ -237,6 +237,7 @@ void FileGenerator::GeneratePBHeader(io::Printer* printer) { } void FileGenerator::GenerateSource(io::Printer* printer) { + bool well_known = IsWellKnownMessage(file_); string header = StripProto(file_->name()) + (options_.proto_h ? ".proto.h" : ".pb.h"); printer->Print( @@ -246,7 +247,7 @@ void FileGenerator::GenerateSource(io::Printer* printer) { // The generated code calls accessors that might be deprecated. We don't // want the compiler to warn in generated code. "#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION\n" - "#include \"$header$\"\n" + "#include $left$$header$$right$\n" "\n" "#include <algorithm>\n" // for swap() "\n" @@ -255,7 +256,9 @@ void FileGenerator::GenerateSource(io::Printer* printer) { "#include <google/protobuf/io/coded_stream.h>\n" "#include <google/protobuf/wire_format_lite_inl.h>\n", "filename", file_->name(), - "header", header); + "header", header, + "left", well_known ? "<" : "\"", + "right", well_known ? ">" : "\""); // Unknown fields implementation in lite mode uses StringOutputStream if (!UseUnknownFieldSet(file_) && file_->message_type_count() > 0) { @@ -857,14 +860,16 @@ void FileGenerator::GenerateDependencyIncludes(io::Printer* printer) { } for (int i = 0; i < file_->dependency_count(); i++) { + bool well_known = IsWellKnownMessage(file_->dependency(i)); const string& name = file_->dependency(i)->name(); bool public_import = (public_import_names.count(name) != 0); - printer->Print( - "#include \"$dependency$.pb.h\"$iwyu$\n", + "#include $left$$dependency$.pb.h$right$$iwyu$\n", "dependency", StripProto(name), - "iwyu", (public_import) ? " // IWYU pragma: export" : ""); + "iwyu", (public_import) ? " // IWYU pragma: export" : "", + "left", well_known ? "<" : "\"", + "right", well_known ? ">" : "\""); } } diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/src/google/protobuf/compiler/cpp/cpp_helpers.cc index 09845458..fb46e387 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.cc +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.cc @@ -54,6 +54,7 @@ namespace { static const char kAnyMessageName[] = "Any"; static const char kAnyProtoFile[] = "google/protobuf/any.proto"; +static const char kGoogleProtobufPrefix[] = "google/protobuf/"; string DotsToUnderscores(const string& name) { return StringReplace(name, ".", "_", true); @@ -600,6 +601,10 @@ bool IsAnyMessage(const Descriptor* descriptor) { descriptor->file()->name() == kAnyProtoFile; } +bool IsWellKnownMessage(const FileDescriptor* descriptor) { + return !descriptor->name().compare(0, 16, kGoogleProtobufPrefix); +} + enum Utf8CheckMode { STRICT = 0, // Parsing will fail if non UTF-8 data is in string fields. VERIFY = 1, // Only log an error but parsing will succeed. diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.h b/src/google/protobuf/compiler/cpp/cpp_helpers.h index 985cb04c..a22d414d 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.h +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.h @@ -265,6 +265,8 @@ inline bool SupportsArenas(const FieldDescriptor* field) { bool IsAnyMessage(const FileDescriptor* descriptor); bool IsAnyMessage(const Descriptor* descriptor); +bool IsWellKnownMessage(const FileDescriptor* descriptor); + void GenerateUtf8CheckCodeForString( const FieldDescriptor* field, bool for_parse, diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc index 8c0bfab7..af409c29 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message.cc @@ -3364,7 +3364,7 @@ GenerateSerializeWithCachedSizesBody(io::Printer* printer, bool to_array) { } else { printer->Print( "output->WriteRaw(unknown_fields().data(),\n" - " unknown_fields().size());\n"); + " static_cast<int>(unknown_fields().size()));\n"); } } } diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc index 266c2975..636673ae 100644 --- a/src/google/protobuf/compiler/plugin.pb.cc +++ b/src/google/protobuf/compiler/plugin.pb.cc @@ -2,7 +2,7 @@ // source: google/protobuf/compiler/plugin.proto #define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include "google/protobuf/compiler/plugin.pb.h" +#include <google/protobuf/compiler/plugin.pb.h> #include <algorithm> diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index ab79bdae..0a03e979 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -27,7 +27,7 @@ #include <google/protobuf/repeated_field.h> #include <google/protobuf/extension_set.h> #include <google/protobuf/unknown_field_set.h> -#include "google/protobuf/descriptor.pb.h" +#include <google/protobuf/descriptor.pb.h> // @@protoc_insertion_point(includes) namespace google { diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index ad53c03f..bc846609 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -2,7 +2,7 @@ // source: google/protobuf/descriptor.proto #define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include "google/protobuf/descriptor.pb.h" +#include <google/protobuf/descriptor.pb.h> #include <algorithm> diff --git a/src/google/protobuf/duration.pb.cc b/src/google/protobuf/duration.pb.cc index 2e22ccb1..c7eed0d5 100644 --- a/src/google/protobuf/duration.pb.cc +++ b/src/google/protobuf/duration.pb.cc @@ -2,7 +2,7 @@ // source: google/protobuf/duration.proto #define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include "google/protobuf/duration.pb.h" +#include <google/protobuf/duration.pb.h> #include <algorithm> @@ -111,10 +111,10 @@ static void MergeFromFail(int line) { // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Duration::kSecondsFieldNumber; const int Duration::kNanosFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 Duration::Duration() : ::google::protobuf::Message(), _internal_metadata_(NULL) { diff --git a/src/google/protobuf/empty.pb.cc b/src/google/protobuf/empty.pb.cc index 50cbd9a8..4a4f6eae 100644 --- a/src/google/protobuf/empty.pb.cc +++ b/src/google/protobuf/empty.pb.cc @@ -2,7 +2,7 @@ // source: google/protobuf/empty.proto #define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include "google/protobuf/empty.pb.h" +#include <google/protobuf/empty.pb.h> #include <algorithm> @@ -108,8 +108,8 @@ static void MergeFromFail(int line) { // =================================================================== -#ifndef _MSC_VER -#endif // !_MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 Empty::Empty() : ::google::protobuf::Message(), _internal_metadata_(NULL) { diff --git a/src/google/protobuf/field_mask.pb.cc b/src/google/protobuf/field_mask.pb.cc index d8f4ee91..f834363b 100644 --- a/src/google/protobuf/field_mask.pb.cc +++ b/src/google/protobuf/field_mask.pb.cc @@ -2,7 +2,7 @@ // source: google/protobuf/field_mask.proto #define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include "google/protobuf/field_mask.pb.h" +#include <google/protobuf/field_mask.pb.h> #include <algorithm> @@ -110,9 +110,9 @@ static void MergeFromFail(int line) { // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int FieldMask::kPathsFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 FieldMask::FieldMask() : ::google::protobuf::Message(), _internal_metadata_(NULL) { diff --git a/src/google/protobuf/source_context.pb.cc b/src/google/protobuf/source_context.pb.cc index c8397639..1be3297e 100644 --- a/src/google/protobuf/source_context.pb.cc +++ b/src/google/protobuf/source_context.pb.cc @@ -2,7 +2,7 @@ // source: google/protobuf/source_context.proto #define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include "google/protobuf/source_context.pb.h" +#include <google/protobuf/source_context.pb.h> #include <algorithm> @@ -110,9 +110,9 @@ static void MergeFromFail(int line) { // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int SourceContext::kFileNameFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 SourceContext::SourceContext() : ::google::protobuf::Message(), _internal_metadata_(NULL) { diff --git a/src/google/protobuf/struct.pb.cc b/src/google/protobuf/struct.pb.cc index d5f89122..273645d9 100644 --- a/src/google/protobuf/struct.pb.cc +++ b/src/google/protobuf/struct.pb.cc @@ -2,7 +2,7 @@ // source: google/protobuf/struct.proto #define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include "google/protobuf/struct.pb.h" +#include <google/protobuf/struct.pb.h> #include <algorithm> @@ -212,9 +212,9 @@ static void MergeFromFail(int line) { // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Struct::kFieldsFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 Struct::Struct() : ::google::protobuf::Message(), _internal_metadata_(NULL) { @@ -480,14 +480,14 @@ Struct::mutable_fields() { // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Value::kNullValueFieldNumber; const int Value::kNumberValueFieldNumber; const int Value::kStringValueFieldNumber; const int Value::kBoolValueFieldNumber; const int Value::kStructValueFieldNumber; const int Value::kListValueFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 Value::Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { @@ -1218,9 +1218,9 @@ Value::KindCase Value::kind_case() const { // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int ListValue::kValuesFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 ListValue::ListValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { diff --git a/src/google/protobuf/timestamp.pb.cc b/src/google/protobuf/timestamp.pb.cc index 2ee0ec29..f0b09195 100644 --- a/src/google/protobuf/timestamp.pb.cc +++ b/src/google/protobuf/timestamp.pb.cc @@ -2,7 +2,7 @@ // source: google/protobuf/timestamp.proto #define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include "google/protobuf/timestamp.pb.h" +#include <google/protobuf/timestamp.pb.h> #include <algorithm> @@ -111,10 +111,10 @@ static void MergeFromFail(int line) { // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Timestamp::kSecondsFieldNumber; const int Timestamp::kNanosFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 Timestamp::Timestamp() : ::google::protobuf::Message(), _internal_metadata_(NULL) { diff --git a/src/google/protobuf/type.pb.cc b/src/google/protobuf/type.pb.cc index 8f993561..5792dff2 100644 --- a/src/google/protobuf/type.pb.cc +++ b/src/google/protobuf/type.pb.cc @@ -2,7 +2,7 @@ // source: google/protobuf/type.proto #define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include "google/protobuf/type.pb.h" +#include <google/protobuf/type.pb.h> #include <algorithm> @@ -282,14 +282,14 @@ static void MergeFromFail(int line) { // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Type::kNameFieldNumber; const int Type::kFieldsFieldNumber; const int Type::kOneofsFieldNumber; const int Type::kOptionsFieldNumber; const int Type::kSourceContextFieldNumber; const int Type::kSyntaxFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 Type::Type() : ::google::protobuf::Message(), _internal_metadata_(NULL) { @@ -967,7 +967,7 @@ bool Field_Kind_IsValid(int value) { } } -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const Field_Kind Field::TYPE_UNKNOWN; const Field_Kind Field::TYPE_DOUBLE; const Field_Kind Field::TYPE_FLOAT; @@ -990,7 +990,7 @@ const Field_Kind Field::TYPE_SINT64; const Field_Kind Field::Kind_MIN; const Field_Kind Field::Kind_MAX; const int Field::Kind_ARRAYSIZE; -#endif // _MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 const ::google::protobuf::EnumDescriptor* Field_Cardinality_descriptor() { protobuf_AssignDescriptorsOnce(); return Field_Cardinality_descriptor_; @@ -1007,7 +1007,7 @@ bool Field_Cardinality_IsValid(int value) { } } -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const Field_Cardinality Field::CARDINALITY_UNKNOWN; const Field_Cardinality Field::CARDINALITY_OPTIONAL; const Field_Cardinality Field::CARDINALITY_REQUIRED; @@ -1015,8 +1015,8 @@ const Field_Cardinality Field::CARDINALITY_REPEATED; const Field_Cardinality Field::Cardinality_MIN; const Field_Cardinality Field::Cardinality_MAX; const int Field::Cardinality_ARRAYSIZE; -#endif // _MSC_VER -#ifndef _MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Field::kKindFieldNumber; const int Field::kCardinalityFieldNumber; const int Field::kNumberFieldNumber; @@ -1026,7 +1026,7 @@ const int Field::kOneofIndexFieldNumber; const int Field::kPackedFieldNumber; const int Field::kOptionsFieldNumber; const int Field::kJsonNameFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 Field::Field() : ::google::protobuf::Message(), _internal_metadata_(NULL) { @@ -1830,13 +1830,13 @@ void Field::clear_json_name() { // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Enum::kNameFieldNumber; const int Enum::kEnumvalueFieldNumber; const int Enum::kOptionsFieldNumber; const int Enum::kSourceContextFieldNumber; const int Enum::kSyntaxFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 Enum::Enum() : ::google::protobuf::Message(), _internal_metadata_(NULL) { @@ -2379,11 +2379,11 @@ void Enum::clear_syntax() { // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int EnumValue::kNameFieldNumber; const int EnumValue::kNumberFieldNumber; const int EnumValue::kOptionsFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 EnumValue::EnumValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { @@ -2775,10 +2775,10 @@ EnumValue::options() const { // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Option::kNameFieldNumber; const int Option::kValueFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 Option::Option() : ::google::protobuf::Message(), _internal_metadata_(NULL) { diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h index deda9213..2533eb4e 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h @@ -28,8 +28,8 @@ #include <google/protobuf/extension_set.h> #include <google/protobuf/generated_enum_reflection.h> #include <google/protobuf/unknown_field_set.h> -#include "google/protobuf/any.pb.h" -#include "google/protobuf/source_context.pb.h" +#include <google/protobuf/any.pb.h> +#include <google/protobuf/source_context.pb.h> // @@protoc_insertion_point(includes) namespace google { diff --git a/src/google/protobuf/wrappers.pb.cc b/src/google/protobuf/wrappers.pb.cc index b2a7e970..e153687b 100644 --- a/src/google/protobuf/wrappers.pb.cc +++ b/src/google/protobuf/wrappers.pb.cc @@ -2,7 +2,7 @@ // source: google/protobuf/wrappers.proto #define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include "google/protobuf/wrappers.pb.h" +#include <google/protobuf/wrappers.pb.h> #include <algorithm> @@ -308,9 +308,9 @@ static void MergeFromFail(int line) { // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int DoubleValue::kValueFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 DoubleValue::DoubleValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { @@ -532,9 +532,9 @@ void DoubleValue::clear_value() { // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int FloatValue::kValueFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 FloatValue::FloatValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { @@ -756,9 +756,9 @@ void FloatValue::clear_value() { // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Int64Value::kValueFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 Int64Value::Int64Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { @@ -982,9 +982,9 @@ void Int64Value::clear_value() { // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int UInt64Value::kValueFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 UInt64Value::UInt64Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { @@ -1208,9 +1208,9 @@ void UInt64Value::clear_value() { // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Int32Value::kValueFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 Int32Value::Int32Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { @@ -1434,9 +1434,9 @@ void Int32Value::clear_value() { // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int UInt32Value::kValueFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 UInt32Value::UInt32Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { @@ -1660,9 +1660,9 @@ void UInt32Value::clear_value() { // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int BoolValue::kValueFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 BoolValue::BoolValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { @@ -1884,9 +1884,9 @@ void BoolValue::clear_value() { // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int StringValue::kValueFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 StringValue::StringValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { @@ -2155,9 +2155,9 @@ void StringValue::clear_value() { // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int BytesValue::kValueFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 BytesValue::BytesValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { |