Skip to content

Commit 2a776bb

Browse files
authored
Merge pull request #39 from Logofile/sync
Project import generated by Copybara.
2 parents 002e00f + 789fe6b commit 2a776bb

File tree

6 files changed

+90
-27
lines changed

6 files changed

+90
-27
lines changed

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) - (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
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ linkTitle: "Language Guide (proto 2)"
66
no_list: "true"
77
type: docs
88
description: "This topic covers how to use the version 2 of Protocol Buffers in your project. It contains language-agnostic content. For information specific to the language you're using, see the corresponding documentation for your language."
9+
aliases:
10+
- /programming-guides/proto/
911
---
1012

1113
This guide describes how to use the protocol buffer language to structure your

content/reference/cpp/cpp-generated.md

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -267,17 +267,19 @@ The compiler will generate the following accessor methods:
267267
whatever value is written into the given string.
268268
- `void clear_foo()`: Clears the value of the field. After calling this,
269269
`has_foo()` will return `false` and `foo()` will return the default value.
270-
- `void set_allocated_foo(string* value)`: Sets the `string` object to the
271-
field and frees the previous field value if it exists. If the `string`
272-
pointer is not `NULL`, the message takes ownership of the allocated `string`
273-
object and `has_foo()` will return `true`. The message is free to delete the
274-
allocated `string` object at any time, so references to the object may be
275-
invalidated. Otherwise, if the `value` is `NULL`, the behavior is the same
276-
as calling `clear_foo()`.
277-
- `string* release_foo()`: Releases the ownership of the field and returns the
278-
pointer of the `string` object. After calling this, caller takes the
279-
ownership of the allocated `string` object, `has_foo()` will return `false`,
280-
and `foo()` will return the default value.
270+
- `void set_allocated_foo(string* value)`:
271+
Sets the `string`
272+
object to the field and frees the previous field value if it exists. If the
273+
`string` pointer is not `NULL`, the message takes ownership of the allocated
274+
`string` object and `has_foo()` will return `true`. The message is free to
275+
delete the allocated `string` object at any time, so references to the
276+
object may be invalidated. Otherwise, if the `value` is `NULL`, the behavior
277+
is the same as calling `clear_foo()`.
278+
- `string* release_foo()`:
279+
Releases the
280+
ownership of the field and returns the pointer of the `string` object. After
281+
calling this, caller takes the ownership of the allocated `string` object,
282+
`has_foo()` will return `false`, and `foo()` will return the default value.
281283

282284
### Singular String Fields (proto3) {#proto3_string}
283285

@@ -309,16 +311,18 @@ The compiler will generate the following accessor methods:
309311
return whatever value is written into the given string.
310312
- `void clear_foo()`: Clears the value of the field. After calling this,
311313
`foo()` will return the empty string/empty bytes.
312-
- `void set_allocated_foo(string* value)`: Sets the `string` object to the
313-
field and frees the previous field value if it exists. If the `string`
314-
pointer is not `NULL`, the message takes ownership of the allocated `string`
315-
object. The message is free to delete the allocated `string` object at any
316-
time, so references to the object may be invalidated. Otherwise, if the
317-
`value` is `NULL`, the behavior is the same as calling `clear_foo()`.
318-
- `string* release_foo()`: Releases the ownership of the field and returns the
319-
pointer of the `string` object. After calling this, caller takes the
320-
ownership of the allocated `string` object and `foo()` will return the empty
321-
string/empty bytes.
314+
- `void set_allocated_foo(string* value)`:
315+
Sets the `string`
316+
object to the field and frees the previous field value if it exists. If the
317+
`string` pointer is not `NULL`, the message takes ownership of the allocated
318+
`string` object. The message is free to delete the allocated `string` object
319+
at any time, so references to the object may be invalidated. Otherwise, if
320+
the `value` is `NULL`, the behavior is the same as calling `clear_foo()`.
321+
- `string* release_foo()`:
322+
Releases the
323+
ownership of the field and returns the pointer of the `string` object. After
324+
calling this, caller takes the ownership of the allocated `string` object
325+
and `foo()` will return the empty string/empty bytes.
322326

323327
### Singular Enum Fields (proto2) {#enum_field}
324328

content/reference/protobuf/proto2-spec.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ package foo.bar;
144144

145145
Options can be used in proto files, messages, enums and services. An option can
146146
be a protobuf defined option or a custom option. For more information, see
147-
[Options](/programming-guides/proto#options) in the language guide.
147+
[Options](/programming-guides/proto#options) in the
148+
language guide.
148149

149150
```
150151
option = "option" optionName "=" constant ";"
@@ -340,6 +341,37 @@ message Outer {
340341
}
341342
```
342343

344+
None of the entities declared inside a message may have conflicting names. All
345+
of the following are prohibited:
346+
347+
```
348+
message MyMessage {
349+
optional string foo = 1;
350+
message foo {}
351+
}
352+
353+
message MyMessage {
354+
optional string foo = 1;
355+
oneof foo {
356+
string bar = 2;
357+
}
358+
}
359+
360+
message MyMessage {
361+
optional string foo = 1;
362+
extend Extendable {
363+
optional string foo = 2;
364+
}
365+
}
366+
367+
message MyMessage {
368+
optional string foo = 1;
369+
enum E {
370+
foo = 0;
371+
}
372+
}
373+
```
374+
343375
### Extend
344376

345377
If a message in the same or imported .proto file has reserved a range for

content/reference/protobuf/proto3-spec.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ package foo.bar;
146146

147147
Options can be used in proto files, messages, enums and services. An option can
148148
be a protobuf defined option or a custom option. For more information, see
149-
[Options](/programming-guides/proto3#options) in the language guide.
149+
[Options](/programming-guides/proto3#options) in the
150+
language guide.
150151

151152
```
152153
option = "option" optionName "=" constant ";"
@@ -292,6 +293,30 @@ message Outer {
292293
}
293294
```
294295

296+
None of the entities declared inside a message may have conflicting names. All
297+
of the following are prohibited:
298+
299+
```
300+
message MyMessage {
301+
optional string foo = 1;
302+
message foo {}
303+
}
304+
305+
message MyMessage {
306+
optional string foo = 1;
307+
oneof foo {
308+
string bar = 2;
309+
}
310+
}
311+
312+
message MyMessage {
313+
optional string foo = 1;
314+
enum E {
315+
foo = 0;
316+
}
317+
}
318+
```
319+
295320
### Service Definition {#service_definition}
296321

297322
```

content/reference/python/python-generated.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ can refer to it as `Foo.Bar`.
133133
## Well Known Types {#wkt}
134134

135135
Protocol buffers provides a number of
136-
[well-known types](/reference/protobuf/google.protobuf.md)
136+
[well-known types](/reference/protobuf/google.protobuf)
137137
that you can use in your .proto files along with your own message types. Some
138138
WKT messages have special methods in addition to the usual protocol buffer
139139
message methods, as they subclass both
@@ -950,7 +950,7 @@ generic services are deprecated. (Note that prior to 2.4.0, the option defaults
950950
to `true`)
951951

952952
RPC systems based on `.proto`-language service definitions should provide
953-
[plugins](/reference/cpp/api-docs/google.protobuf.compiler.plugin.pb.md)
953+
[plugins](/reference/cpp/api-docs/google.protobuf.compiler.plugin.pb)
954954
to generate code appropriate for the system. These plugins are likely to require
955955
that abstract services are disabled, so that they can generate their own classes
956956
of the same names. Plugins are new in version 2.3.0 (January 2010).
@@ -1017,7 +1017,7 @@ implementations of `RpcChannel` and
10171017

10181018
## Plugin Insertion Points {#plugins}
10191019

1020-
[Code generator plugins](/reference/cpp/api-docs/google.protobuf.compiler.plugin.pb.md)
1020+
[Code generator plugins](/reference/cpp/api-docs/google.protobuf.compiler.plugin)
10211021
which want to extend the output of the Python code generator may insert code of
10221022
the following types using the given insertion point names.
10231023

0 commit comments

Comments
 (0)