Commit 58cd4a47 authored by Thomas Van Lenten's avatar Thomas Van Lenten

ObjC fixup for the branch.

- Shouldn't need SRCROOT in the project since Xcode should be setting the working directory to where the project lives.
- Remove the packed/unpacked repeated enum field in the tests and update the code to handle the defaults.
- Move up the ignore to cover .DS_Store files in src also.

add starstar
parent 8e142680
...@@ -92,7 +92,8 @@ objectivec/ProtocolBuffers_OSX.xcodeproj/xcuserdata/ ...@@ -92,7 +92,8 @@ objectivec/ProtocolBuffers_OSX.xcodeproj/xcuserdata/
objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcuserdata/ objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcuserdata/
objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcshareddata/ProtocolBuffers_iOS.xccheckout objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcshareddata/ProtocolBuffers_iOS.xccheckout
objectivec/ProtocolBuffers_iOS.xcodeproj/xcuserdata/ objectivec/ProtocolBuffers_iOS.xcodeproj/xcuserdata/
objectivec/**/.DS_Store # OS X's Finder creates these for state about opened windows/etc.
**/.DS_Store
# Comformance test output # Comformance test output
conformance/.libs/ conformance/.libs/
......
...@@ -725,7 +725,7 @@ ...@@ -725,7 +725,7 @@
INFOPLIST_FILE = "Tests/UnitTests-Info.plist"; INFOPLIST_FILE = "Tests/UnitTests-Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_NAME = UnitTests; PRODUCT_NAME = UnitTests;
SWIFT_OBJC_BRIDGING_HEADER = "$(SRCROOT)/Tests/UnitTests-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Tests/UnitTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_OPTIMIZATION_LEVEL = "-Onone";
}; };
name = Debug; name = Debug;
...@@ -742,7 +742,7 @@ ...@@ -742,7 +742,7 @@
INFOPLIST_FILE = "Tests/UnitTests-Info.plist"; INFOPLIST_FILE = "Tests/UnitTests-Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_NAME = UnitTests; PRODUCT_NAME = UnitTests;
SWIFT_OBJC_BRIDGING_HEADER = "$(SRCROOT)/Tests/UnitTests-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Tests/UnitTests-Bridging-Header.h";
}; };
name = Release; name = Release;
}; };
......
...@@ -875,7 +875,7 @@ ...@@ -875,7 +875,7 @@
"\"$(DEVELOPER_DIR)/usr/lib\"", "\"$(DEVELOPER_DIR)/usr/lib\"",
); );
PRODUCT_NAME = UnitTests; PRODUCT_NAME = UnitTests;
SWIFT_OBJC_BRIDGING_HEADER = "$(SRCROOT)/Tests/UnitTests-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Tests/UnitTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iOSTestHarness.app/iOSTestHarness"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iOSTestHarness.app/iOSTestHarness";
...@@ -903,7 +903,7 @@ ...@@ -903,7 +903,7 @@
"\"$(DEVELOPER_DIR)/usr/lib\"", "\"$(DEVELOPER_DIR)/usr/lib\"",
); );
PRODUCT_NAME = UnitTests; PRODUCT_NAME = UnitTests;
SWIFT_OBJC_BRIDGING_HEADER = "$(SRCROOT)/Tests/UnitTests-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Tests/UnitTests-Bridging-Header.h";
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iOSTestHarness.app/iOSTestHarness"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iOSTestHarness.app/iOSTestHarness";
}; };
......
...@@ -146,9 +146,6 @@ static NSData *DataFromCStr(const char *str) { ...@@ -146,9 +146,6 @@ static NSData *DataFromCStr(const char *str) {
orig.repeatedEnumArray = orig.repeatedEnumArray =
[GPBEnumArray arrayWithValidationFunction:Message3_Enum_IsValidValue [GPBEnumArray arrayWithValidationFunction:Message3_Enum_IsValidValue
rawValue:Message3_Enum_Extra3]; rawValue:Message3_Enum_Extra3];
orig.repeatedPackedEnumArray =
[GPBEnumArray arrayWithValidationFunction:Message3_Enum_IsValidValue
rawValue:Message3_Enum_Extra3];
orig.oneofEnum = Message3_Enum_Extra3; orig.oneofEnum = Message3_Enum_Extra3;
Message2 *msg = [[Message2 alloc] initWithData:[orig data] error:NULL]; Message2 *msg = [[Message2 alloc] initWithData:[orig data] error:NULL];
...@@ -157,19 +154,16 @@ static NSData *DataFromCStr(const char *str) { ...@@ -157,19 +154,16 @@ static NSData *DataFromCStr(const char *str) {
XCTAssertFalse(msg.hasOptionalEnum); XCTAssertFalse(msg.hasOptionalEnum);
XCTAssertEqual(msg.repeatedEnumArray.count, 0U); XCTAssertEqual(msg.repeatedEnumArray.count, 0U);
XCTAssertEqual(msg.repeatedPackedEnumArray.count, 0U);
XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_GPBUnsetOneOfCase); XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_GPBUnsetOneOfCase);
// All the values should be in unknown fields. // All the values should be in unknown fields.
GPBUnknownFieldSet *unknownFields = msg.unknownFields; GPBUnknownFieldSet *unknownFields = msg.unknownFields;
XCTAssertEqual([unknownFields countOfFields], 4U); XCTAssertEqual([unknownFields countOfFields], 3U);
XCTAssertTrue([unknownFields hasField:Message2_FieldNumber_OptionalEnum]); XCTAssertTrue([unknownFields hasField:Message2_FieldNumber_OptionalEnum]);
XCTAssertTrue( XCTAssertTrue(
[unknownFields hasField:Message2_FieldNumber_RepeatedEnumArray]); [unknownFields hasField:Message2_FieldNumber_RepeatedEnumArray]);
XCTAssertTrue(
[unknownFields hasField:Message2_FieldNumber_RepeatedPackedEnumArray]);
XCTAssertTrue([unknownFields hasField:Message2_FieldNumber_OneofEnum]); XCTAssertTrue([unknownFields hasField:Message2_FieldNumber_OneofEnum]);
GPBField *field = [unknownFields getField:Message2_FieldNumber_OptionalEnum]; GPBField *field = [unknownFields getField:Message2_FieldNumber_OptionalEnum];
...@@ -177,22 +171,12 @@ static NSData *DataFromCStr(const char *str) { ...@@ -177,22 +171,12 @@ static NSData *DataFromCStr(const char *str) {
XCTAssertEqual([field.varintList valueAtIndex:0], XCTAssertEqual([field.varintList valueAtIndex:0],
(uint64_t)Message3_Enum_Extra3); (uint64_t)Message3_Enum_Extra3);
// TODO(teboring): This test could fail without explicitly marking the repeated_enum in Message3 // Repeated in proto3 default to packed, so this will be length delimited
// to be unpacked. This is becaucse proto3 repeated primitive field is packed by default. However, // unknown field, and the value (Message3_Enum_Extra3) encodes into one byte.
// the proto2 primitive repeated field is still unpacked by default. Previously, parsing of the
// repeated_enum field would fail. To fix it:
// 1) Objective-C implementation of parsing should be able to parse packed field for unpacked
// field and vice versa.
// 2) repeated_packed_enum in Message3 should be removed, because it's unnecessary now.
field = [unknownFields getField:Message2_FieldNumber_RepeatedEnumArray]; field = [unknownFields getField:Message2_FieldNumber_RepeatedEnumArray];
XCTAssertEqual(field.varintList.count, 1U); XCTAssertEqual(field.lengthDelimitedList.count, 1U);
XCTAssertEqual([field.varintList valueAtIndex:0], NSData *expected = DataFromCStr("\x1E");
(uint64_t)Message3_Enum_Extra3); XCTAssertEqualObjects([field.lengthDelimitedList objectAtIndex:0], expected);
field = [unknownFields getField:Message2_FieldNumber_RepeatedPackedEnumArray];
XCTAssertEqual(field.varintList.count, 1U);
XCTAssertEqual([field.varintList valueAtIndex:0],
(uint64_t)Message3_Enum_Extra3);
field = [unknownFields getField:Message2_FieldNumber_OneofEnum]; field = [unknownFields getField:Message2_FieldNumber_OneofEnum];
XCTAssertEqual(field.varintList.count, 1U); XCTAssertEqual(field.varintList.count, 1U);
......
...@@ -78,9 +78,8 @@ message Message2 { ...@@ -78,9 +78,8 @@ message Message2 {
repeated group RepeatedGroup = 46 { repeated group RepeatedGroup = 46 {
optional int32 a = 47; optional int32 a = 47;
} }
repeated Message2 repeated_message = 48; repeated Message2 repeated_message = 48;
repeated Enum repeated_enum = 49; repeated Enum repeated_enum = 49;
repeated Enum repeated_packed_enum = 50 [packed=true];
oneof o { oneof o {
int32 oneof_int32 = 51 [default = 100]; int32 oneof_int32 = 51 [default = 100];
......
...@@ -75,11 +75,7 @@ message Message3 { ...@@ -75,11 +75,7 @@ message Message3 {
repeated bytes repeated_bytes = 45; repeated bytes repeated_bytes = 45;
// No 'group' in proto3. // No 'group' in proto3.
repeated Message3 repeated_message = 48; repeated Message3 repeated_message = 48;
// TODO(teboring): In proto3, repeated primitive field is packed by default. repeated Enum repeated_enum = 49;
// testProto2UnknownEnumToUnknownField needs repeated_enum to be unpacked.
// Remove this option when testProto2UnknownEnumToUnknownField.
repeated Enum repeated_enum = 49 [packed=false];
repeated Enum repeated_packed_enum = 50 [packed=true];
oneof o { oneof o {
int32 oneof_int32 = 51; int32 oneof_int32 = 51;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment