Skip to content

Commit 002e00f

Browse files
authored
Merge pull request #38 from Logofile/sync
Project import generated by Copybara.
2 parents de9967d + f713193 commit 002e00f

File tree

15 files changed

+130
-86
lines changed

15 files changed

+130
-86
lines changed

content/_index.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ message Person {
3636
</div>
3737
<div class="col-md">
3838

39-
```proto
39+
```java
40+
// Java code
4041
Person john = Person.newBuilder()
4142
.setId(1234)
4243
.setName("John Doe")
@@ -51,7 +52,8 @@ john.writeTo(output);
5152
</div>
5253
<div class="col-md">
5354

54-
```proto
55+
```cpp
56+
// C++ code
5557
Person john;
5658
fstream input(argv[1],
5759
ios::in | ios::binary);

content/includes/version-tables.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
table tbody, th, td {
2-
border: 1px solid #818589;
2+
border: 1px solid #818589 !important;
33
padding-top: 2px;
44
padding-bottom: 2px;
55
padding-left: 5px;

content/programming-guides/api.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,10 @@ system."
668668
If the enhancement field in `PhotoEnhancementReply` were a scalar or enum, this
669669
would be much harder to support.
670670

671+
This applies equally to maps. It is much easier to add additional fields to a
672+
map value if it's already a message rather than having to migrate from
673+
`map<string, string>` to `map<string, MyProto>`.
674+
671675
One exception:
672676

673677
Latency-critical applications will find parallel arrays of primitive types are

content/programming-guides/encoding.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ Signed Original | Encoded As
204204
Using some bit tricks, it's cheap to convert `n` into its ZigZag representation:
205205

206206
```
207-
n + n + (n < 0)
207+
(n + n) ^ -(n < 0) - (n < 0)
208208
```
209209

210210
Here, we assume that the boolean `n < 0` is converted into an integer 1 if true

content/reference/cpp/api-docs/google.protobuf.map.md

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

content/reference/cpp/cpp-generated.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ generated code are highlighted - note that these differences are in the
1515
generated code as described in this document, not the base message
1616
classes/interfaces, which are the same in both versions. You should read the
1717
[proto2 language guide](/programming-guides/proto) and/or
18-
[proto3 language guide](/programming-guides/proto3) before reading this
19-
document.
18+
[proto3 language guide](/programming-guides/proto3)
19+
before reading this document.
2020

2121
## Compiler Invocation {#invocation}
2222

@@ -465,8 +465,8 @@ The compiler will generate the following accessor methods:
465465
- `int foo_size() const`: Returns the number of elements currently in the
466466
field.
467467
- `const string& foo(int index) const`: Returns the element at the given
468-
zero-based index. Calling this method with index outside of [0, foo_size()-1]
469-
yields undefined behavior.
468+
zero-based index. Calling this method with index outside of [0,
469+
foo_size()-1] yields undefined behavior.
470470
- `void set_foo(int index, const string& value)`: Sets the value of the
471471
element at the given zero-based index.
472472
- `void set_foo(int index, const char* value)`: Sets the value of the element
@@ -885,7 +885,8 @@ it is put into a map field as if it is a known enum value.
885885

886886
## Any
887887

888-
Given an [`Any`](/programming-guides/proto3#any) field like this:
888+
Given an [`Any`](/programming-guides/proto3#any) field
889+
like this:
889890

890891
```proto
891892
import "google/protobuf/any.proto";

content/reference/csharp/csharp-generated.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ description: "This topic describes exactly what C# code the protocol buffer comp
1111

1212
This page describes exactly what C\# code the protocol buffer compiler generates
1313
for protocol definitions using `proto3` syntax. You should read the
14-
[proto3 language guide](/programming-guides/proto3) before reading this
15-
document.
14+
[proto3 language guide](/programming-guides/proto3)
15+
before reading this document.
1616

1717
{{% alert title="Note" color="note" %}}
18-
The protobuf compiler can generate C\# interfaces for definitions
19-
using `proto2` syntax starting from release 3.10. Refer to the
20-
[proto2 language guide](/programming-guides/proto) for details of the
21-
semantics of `proto2` definitions, and see `docs/csharp/proto2.md`
18+
The protobuf compiler can generate C\# interfaces for definitions using `proto2`
19+
syntax starting from release 3.10. Refer to the
20+
[proto2 language guide](/programming-guides/proto) for
21+
details of the semantics of `proto2` definitions, and see
22+
`docs/csharp/proto2.md`
2223
([view on GitHub](https://github.com/protocolbuffers/protobuf/blob/master/docs/csharp/proto2.md))
2324
for details on the generated C\# code for proto2.
2425
{{% /alert %}}
@@ -109,7 +110,8 @@ The `namespace` is inferred from the proto's `package`, using the same
109110
conversion rules as the file name. For example, a proto package of
110111
`example.high_score` would result in a namespace of `Example.HighScore`. You can
111112
override the default generated namespace for a particular .proto using the
112-
`csharp_namespace` [file option](/programming-guides/proto3#options).
113+
`csharp_namespace`
114+
[file option](/programming-guides/proto3#options).
113115
114116
Each top-level enum and message results in an enum or class being declared as
115117
members of the namespace. Additionally, a single static partial class is always

content/reference/dart/dart-generated.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ any given protocol definition. Any differences between proto2 and proto3
1414
generated code are highlighted - note that these differences are in the
1515
generated code as described in this document, not the base API, which are the
1616
same in both versions. You should read the
17-
[proto2 language guide](/programming-guides/proto) and/or the
18-
[proto3 language guide](/programming-guides/proto3) before reading this
19-
document.
17+
[proto2 language guide](/programming-guides/proto) and/or
18+
the [proto3 language guide](/programming-guides/proto3)
19+
before reading this document.
2020

2121
## Compiler Invocation {#invocation}
2222

@@ -101,8 +101,8 @@ message in the `.proto` file.
101101

102102
Note that the generated names always use camel-case naming, even if the field
103103
name in the `.proto` file uses lower-case with underscores
104-
([as it should](/programming-guides/style)). The case-conversion works
105-
as follows:
104+
([as it should](/programming-guides/style)). The
105+
case-conversion works as follows:
106106

107107
1. For each underscore in the name, the underscore is removed, and the
108108
following letter is capitalized.
@@ -132,7 +132,8 @@ The compiler will generate the following accessor methods in the message class:
132132
`hasFoo()` will return `false` and `get foo` will return the default value.
133133

134134
For other simple field types, the corresponding Dart type is chosen according to
135-
the [scalar value types table](/programming-guides/proto#scalar).
135+
the
136+
[scalar value types table](/programming-guides/proto#scalar).
136137
For message and enum types, the value type is replaced with the message or enum
137138
class.
138139

@@ -228,7 +229,8 @@ import 'package:fixnum/fixnum.dart';
228229

229230
### Map Fields
230231

231-
Given a [`map`](/programming-guides/proto3#maps) field definition like this:
232+
Given a [`map`](/programming-guides/proto3#maps) field
233+
definition like this:
232234

233235
```proto
234236
map<int32, int32> map_field = 1;
@@ -242,7 +244,8 @@ The compiler will generate the following getter:
242244

243245
## Any
244246

245-
Given an [`Any`](/programming-guides/proto3#any) field like this:
247+
Given an [`Any`](/programming-guides/proto3#any) field
248+
like this:
246249

247250
```proto
248251
import "google/protobuf/any.proto";
@@ -285,7 +288,8 @@ and unpack the `Any`'s values:
285288

286289
## Oneof
287290

288-
Given a [`oneof`](/programming-guides/proto3#oneof) definition like this:
291+
Given a [`oneof`](/programming-guides/proto3#oneof)
292+
definition like this:
289293

290294
```proto
291295
message Foo {
@@ -383,8 +387,8 @@ The protocol buffer compiler will generate a class called `Bar`, which extends
383387
## Extensions (proto2 only) {#extension}
384388

385389
Given a file `foo_test.proto` including a message with an
386-
[extension range](/programming-guides/proto#extensions) and a top-level
387-
extension definition:
390+
[extension range](/programming-guides/proto#extensions)
391+
and a top-level extension definition:
388392

389393
```proto
390394
message Foo {

content/reference/kotlin/kotlin-generated.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ description: "This topic describes exactly what Kotlin code the protocol buffer
1111

1212
This page describes exactly what Kotlin code the protocol buffer compiler
1313
generates for any given protocol definition, in addition to the code generated
14-
for [Java](/reference/java/java-generated). Any differences
15-
between proto2 and proto3 generated code are highlighted&mdash;note that these
16-
differences are in the generated code as described in this document, not the
17-
base message classes/interfaces, which are the same in both versions. You should
18-
read the [proto2 language guide](/programming-guides/proto) and/or
19-
[proto3 language guide](/programming-guides/proto3) before reading this
20-
document.
14+
for [Java](/reference/java/java-generated). Any
15+
differences between proto2 and proto3 generated code are highlighted&mdash;note
16+
that these differences are in the generated code as described in this document,
17+
not the base message classes/interfaces, which are the same in both versions.
18+
You should read the
19+
[proto2 language guide](/programming-guides/proto) and/or
20+
[proto3 language guide](/programming-guides/proto3)
21+
before reading this document.
2122

2223
## Compiler Invocation {#invocation}
2324

@@ -117,8 +118,8 @@ properties on the message object from the getters generated by Java.)
117118

118119
Note that properties always use camel-case naming, even if the field name in the
119120
`.proto` file uses lower-case with underscores
120-
([as it should](/programming-guides/style)). The case-conversion works
121-
as follows:
121+
([as it should](/programming-guides/style)). The
122+
case-conversion works as follows:
122123

123124
1. For each underscore in the name, the underscore is removed, and the
124125
following letter is capitalized.
@@ -149,7 +150,8 @@ The compiler will generate the following accessors in the DSL:
149150
`hasFoo()` will return `false` and `getFoo()` will return the default value.
150151

151152
For other simple field types, the corresponding Java type is chosen according to
152-
the [scalar value types table](/programming-guides/proto#scalar).
153+
the
154+
[scalar value types table](/programming-guides/proto#scalar).
153155
For message and enum types, the value type is replaced with the message or enum
154156
class. As the message type is still defined in Java, unsigned types in the
155157
message are represented using the standard corresponding signed types in the
@@ -192,7 +194,8 @@ The compiler will generate the following property in the DSL:
192194
`getFoo()` will return the default value for the field's type.
193195

194196
For other simple field types, the corresponding Java type is chosen according to
195-
the [scalar value types table](/programming-guides/proto#scalar).
197+
the
198+
[scalar value types table](/programming-guides/proto#scalar).
196199
For message and enum types, the value type is replaced with the message or enum
197200
class. As the message type is still defined in Java, unsigned types in the
198201
message are represented using the standard corresponding signed types in the
@@ -257,7 +260,8 @@ underlying builder, while preventing mutability from \"escaping\" the DSL, which
257260
could cause confusing side effects.
258261

259262
For other simple field types, the corresponding Java type is chosen according to
260-
the [scalar value types table](/programming-guides/proto#scalar).
263+
the
264+
[scalar value types table](/programming-guides/proto#scalar).
261265
For message and enum types, the type is the message or enum class.
262266

263267
### Oneof Fields
@@ -283,7 +287,8 @@ The compiler will generate the following accessor methods in the DSL:
283287
is `FOO`. Otherwise, returns the default value of this field.
284288

285289
For other simple field types, the corresponding Java type is chosen according to
286-
the [scalar value types table](/programming-guides/proto#scalar).
290+
the
291+
[scalar value types table](/programming-guides/proto#scalar).
287292
For message and enum types, the value type is replaced with the message or enum
288293
class.
289294

content/reference/objective-c/objective-c-generated.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ This page describes exactly what Objective-C code the protocol buffer compiler
1313
generates for any given protocol definition. Any differences between proto2 and
1414
proto3 generated code are highlighted. You should read the
1515
[proto2 language guide](/programming-guides/proto) and/or
16-
[proto3 language guide](/programming-guides/proto3) before reading this
17-
document.
16+
[proto3 language guide](/programming-guides/proto3)
17+
before reading this document.
1818

1919
## Compiler invocation {#invocation}
2020

@@ -171,11 +171,11 @@ The behaviors for this interface are as follows:
171171
### Unknown fields (proto2 only)
172172

173173
If a message created with an
174-
[older version](/programming-guides/proto#updating) of your .proto
175-
definition is parsed with code generated from a newer version (or vice versa),
176-
the message may contain optional or repeated fields that the \"new\" code does
177-
not recognize. In proto2 generated code, these fields are not discarded and are
178-
stored in the message's `unknownFields` property.
174+
[older version](/programming-guides/proto#updating) of
175+
your .proto definition is parsed with code generated from a newer version (or
176+
vice versa), the message may contain optional or repeated fields that the
177+
\"new\" code does not recognize. In proto2 generated code, these fields are not
178+
discarded and are stored in the message's `unknownFields` property.
179179

180180
```objc
181181
@property(nonatomic, copy, nullable) GPBUnknownFieldSet *unknownFields;
@@ -289,8 +289,8 @@ typedef GPB_ENUM(Foo_FieldNumber) {
289289
290290
#### Default values {#default}
291291
292-
The [default value](/programming-guides/proto3#default) for
293-
numeric types is `0`.
292+
The [default value](/programming-guides/proto3#default)
293+
for numeric types is `0`.
294294
295295
The default value for strings is `@""`, and the default value for bytes is
296296
`[NSData data]`.
@@ -443,8 +443,8 @@ typedef GPB_ENUM(Foo_FieldNumber) {
443443
444444
#### Default values (optional fields only) {#default}
445445
446-
The [default value](/programming-guides/proto#optional) for
447-
numeric types, if no explicit default was specified by the user, is `0`.
446+
The [default value](/programming-guides/proto#optional)
447+
for numeric types, if no explicit default was specified by the user, is `0`.
448448
449449
The default value for strings is `@""`, and the default value for bytes is
450450
`[NSData data]`.
@@ -542,10 +542,10 @@ For string, bytes and message fields, elements of the array are `NSString*`,
542542
543543
#### Default values {#repeateddefault}
544544
545-
The [default value](/programming-guides/proto3#default) for a
546-
repeated field is to be empty. In Objective-C generated code, this is an empty
547-
`GPB<VALUE>Array`. If you access an empty repeated field, you'll get back an
548-
empty array that you can update like any other repeated field array.
545+
The [default value](/programming-guides/proto3#default)
546+
for a repeated field is to be empty. In Objective-C generated code, this is an
547+
empty `GPB<VALUE>Array`. If you access an empty repeated field, you'll get back
548+
an empty array that you can update like any other repeated field array.
549549
550550
```objc
551551
Foo *myFoo = [[Foo alloc] init];
@@ -677,8 +677,9 @@ function and to access raw values.
677677

678678
### Oneof fields {#oneof}
679679

680-
Given a message with [oneof](/programming-guides/proto3#oneof)
681-
field definitions:
680+
Given a message with
681+
[oneof](/programming-guides/proto3#oneof) field
682+
definitions:
682683

683684
```proto
684685
message Order {
@@ -769,8 +770,8 @@ where:
769770

770771
#### Default values {#repeateddefault}
771772

772-
The [default value](/programming-guides/proto3#default) for a map
773-
field is empty. In Objective-C generated code, this is an empty
773+
The [default value](/programming-guides/proto3#default)
774+
for a map field is empty. In Objective-C generated code, this is an empty
774775
`GBP<KEY><VALUE>Dictionary`. If you access an empty map field, you'll get back
775776
an empty dictionary that you can update like any other map field.
776777

@@ -1100,9 +1101,9 @@ If you use any of the message types provided with proto3, they will in general
11001101
just use their proto definitions in generated Objective-C code, though we supply
11011102
some basic conversion methods in categories to make using them simpler. Note
11021103
that we do not have special APIs for all well-known types yet, including
1103-
[`Any`](/programming-guides/proto3#any) (there is currently no
1104-
helper method to convert an `Any`'s message value into a message of the
1105-
appropriate type).
1104+
[`Any`](/programming-guides/proto3#any) (there is
1105+
currently no helper method to convert an `Any`'s message value into a message of
1106+
the appropriate type).
11061107

11071108
### Time Stamps
11081109

0 commit comments

Comments
 (0)