Skip to content

Commit c641ee0

Browse files
Protocol Buffer TeamLogofile
authored andcommitted
Project import generated by Copybara.
PiperOrigin-RevId: 503164845 Change-Id: I75045c85d12a8e373d46d6766675e645b70a580c
1 parent 4ecd7cf commit c641ee0

File tree

5 files changed

+134
-111
lines changed

5 files changed

+134
-111
lines changed

content/programming-guides/api.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -652,12 +652,12 @@ message PhotoEnhancement {
652652
message PhotoEnhancementReply {
653653
// Good: PhotoEnhancement can grow to describe enhancements that require
654654
// more fields than just an enum.
655-
repeated PhotoEnhancement enhancement;
655+
repeated PhotoEnhancement enhancements;
656656
657657
// Bad: If we ever want to return parameters associated with the
658658
// enhancement, we'd have to introduce a parallel array (terrible) or
659659
// deprecate this field and introduce a repeated message.
660-
repeated EnhancementType enhancement_type;
660+
repeated EnhancementType enhancement_types;
661661
}
662662
```
663663

@@ -888,9 +888,9 @@ pass the two related fields around inside your own service.
888888
message BatchEquationSolverResponse {
889889
// Bad: Solved values are returned in the order of the equations given in
890890
// the request.
891-
repeated double solved_value;
892-
// (Usually) Bad: Parallel array for solved_value.
893-
repeated double solved_complex_value;
891+
repeated double solved_values;
892+
// (Usually) Bad: Parallel array for solved_values.
893+
repeated double solved_complex_values;
894894
}
895895
896896
// Good: A separate message that can grow to include more fields and be
@@ -899,7 +899,7 @@ message BatchEquationSolverResponse {
899899
message BatchEquationSolverResponse {
900900
// Deprecated, this will continue to be populated in responses until Q2
901901
// 2014, after which clients must move to using the solutions field below.
902-
repeated double solved_value [deprecated = true];
902+
repeated double solved_values [deprecated = true];
903903
904904
// Good: Each equation in the request has a unique identifier that's
905905
// included in the EquationSolution below so that the solutions can be

content/programming-guides/encoding.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,8 @@ as Protoscope text,
387387
6: {3 270 86942}
388388
```
389389

390-
Only repeated fields of primitive numeric types (types) can be declared
391-
"packed". These are types that would normally use the `VARINT`, `I32`, or `I64`
392-
wire types.
390+
Only repeated fields of primitive numeric types can be declared "packed". These
391+
are types that would normally use the `VARINT`, `I32`, or `I64` wire types.
393392

394393
Note that although there's usually no reason to encode more than one key-value
395394
pair for a packed repeated field, parsers must be prepared to accept multiple

content/programming-guides/proto3.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,9 +1065,11 @@ language in the relevant [API reference](/reference/).
10651065
```c++
10661066
SampleMessage message;
10671067
message.set_name("name");
1068-
CHECK(message.has_name());
1069-
message.mutable_sub_message(); // Will clear name field.
1070-
CHECK(!message.has_name());
1068+
CHECK_EQ(message.name(), "name");
1069+
// Calling mutable_sub_message() will clear the name field and will set
1070+
// sub_message to a new instance of SubMessage with none of its fields set.
1071+
message.mutable_sub_message();
1072+
CHECK(message.name().empty());
10711073
```
10721074

10731075
* If the parser encounters multiple members of the same oneof on the wire,
@@ -1103,7 +1105,7 @@ language in the relevant [API reference](/reference/).
11031105
msg2.mutable_sub_message();
11041106
msg1.swap(&msg2);
11051107
CHECK(msg1.has_sub_message());
1106-
CHECK(msg2.has_name());
1108+
CHECK_EQ(msg2.name(), "name");
11071109
```
11081110

11091111
### Backwards-compatibility issues

content/programming-guides/style.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ enum FooBar {
102102

103103
Each enum value should end with a semicolon, not a comma. Prefer prefixing enum
104104
values instead of surrounding them in an enclosing message. The zero value enum
105-
should have the suffix `UNSPECIFIED`.
105+
should have the suffix `UNSPECIFIED`, because a server or application that gets
106+
an unexpected enum value will mark the field as unset in the proto instance. The
107+
field accessor will then return the default value, which for enum fields is the
108+
first enum value.
106109

107110
## Services {#services}
108111

0 commit comments

Comments
 (0)