Skip to content

Commit bf57474

Browse files
authored
Merge pull request #203 from Logofile/sync
Documentation change
2 parents 4f1af83 + 8cd6715 commit bf57474

File tree

7 files changed

+65
-12
lines changed

7 files changed

+65
-12
lines changed

content/news/2024-12-13.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
+++
2+
title = "Changes announced December 13, 2024"
3+
linkTitle = "December 13, 2024"
4+
toc_hide = "true"
5+
description = "Changes announced for Protocol Buffers on December 13, 2024."
6+
type = "docs"
7+
+++
8+
9+
## Removing a Reflection-related Function
10+
11+
In v30.x, we are removing the following reflection-related function:
12+
`MutableRepeatedFieldRef<T>::Reserve()`.
13+
14+
An upcoming performance improvement in
15+
[`RepeatedPtrField`](/reference/cpp/api-docs/google.protobuf.repeated_field#RepeatedPtrField)
16+
is incompatible with this API. The improvement is projected to accelerate
17+
repeated access to the elements of `RepeatedPtrField`, in particular and
18+
especially sequential access.

content/news/v30.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ be parseable by Protobuf TextFormat Parsers.
5555
Read more about this in the
5656
[news article released November 21, 2024](/news/2024-11-21).
5757

58+
### Removing a a Reflection-related Function {#removing-mutable-repeated}
59+
60+
We are removing the following reflection-related function:
61+
`MutableRepeatedFieldRef<T>::Reserve()`.
62+
63+
An upcoming performance improvement in
64+
[`RepeatedPtrField`](/reference/cpp/api-docs/google.protobuf.repeated_field#RepeatedPtrField)
65+
is incompatible with this API. The improvement is projected to accelerate
66+
repeated access to the elements of `RepeatedPtrField`, in particular and
67+
especially sequential access.
68+
5869
### Remove Deprecated APIs {#remove-deprecated}
5970

6071
v30 will remove the following public runtime APIs, which have been marked

content/programming-guides/style.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,18 @@ enum FooBar {
9898
}
9999
```
100100

101-
Each enum value should end with a semicolon, not a comma. Prefer prefixing enum
102-
values instead of surrounding them in an enclosing message. Since some languages
103-
don't support an enum being defined inside a "struct" type, this ensures a
104-
consistent approach across binding languages.
101+
Each enum value should end with a semicolon, not a comma.
102+
103+
Since the enum values are semantically not scoped by their containing enum name,
104+
the same value name in two sibling enums is not allowed. A name collision issue
105+
is especially a risk for top level enums, since in that case their siblings may
106+
be defined in another file which has the same package. To avoid these risks, it
107+
is strongly recommended to either prefix every value with the enum name or to
108+
nest the enum inside a containing message.
109+
110+
Prefer using top-level enums with prefixed values over nesting them inside a
111+
message. Since some languages don't support an enum being defined inside a
112+
"struct" type, this ensures a consistent approach across binding languages.
105113

106114
The zero value enum should have the suffix `UNSPECIFIED`, because a server or
107115
application that gets an unexpected enum value will mark the field as unset in

content/reference/cpp/cpp-generated.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ The compiler will generate the following accessor methods:
658658
[`RepeatedPtrField`](/reference/cpp/api-docs/google.protobuf.repeated_field#RepeatedPtrField)
659659
that stores the field's elements. This container class provides STL-like
660660
iterators and other methods.
661-
- `RepeatedPtrField<Bar>* mutable_foo()`: Returns a pointer to the underlying
661+
- `RepeatedPtrField<Bar>* mutable_bar()`: Returns a pointer to the underlying
662662
mutable `RepeatedPtrField` that stores the field's elements. This container
663663
class provides STL-like iterators and other methods.
664664

content/reference/java/java-generated.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ are not expected to start with a backwards domain name.
132132

133133
## Messages {#message}
134134

135+
If you are designing a new protocol buffer schema, see
136+
[the recommendations for Java proto names](/reference/java/java-proto-names).
137+
135138
Given a simple message declaration:
136139

137140
```proto

content/reference/rust/rust-generated.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,10 @@ Additionally, it will generate the two accessors:
525525
Given an enum definition like:
526526

527527
```proto
528-
enum Foo {
529-
VALUE_A = 0;
530-
VALUE_B = 5;
528+
enum FooBar {
529+
FOO_BAR_UNKNOWN = 0;
530+
FOO_BAR_A = 1;
531+
FOO_B = 5;
531532
VALUE_C = 1234;
532533
}
533534
```
@@ -536,16 +537,24 @@ The compiler will generate:
536537

537538
```rust
538539
#[derive(Clone, Copy, PartialEq, Eq)]
539-
540540
pub struct Foo(i32);
541541

542-
impl Foo {
543-
pub const ValueA: Foo = Foo(0);
544-
pub const ValueB: Foo = Foo(5);
542+
impl FooBar {
543+
pub const Unknown: Foo = Foo(0);
544+
pub const A: Foo = Foo(1);
545+
pub const FooB: Foo = Foo(5);
545546
pub const ValueC: Foo = Foo(1234);
546547
}
547548
```
548549

550+
Note that for values with a prefix that matches the enum, the prefix will be
551+
stripped; this is done to improve ergonomics. Enum values are commonly prefixed
552+
with the enum name to avoid name collisions between sibling enums (which follow
553+
the semantics of C++ enums where the values are not scoped by their containing
554+
enum). Since the generated Rust consts are scoped within the `impl`, the
555+
additional prefix, which is beneficial to add in .proto files, would be
556+
redundant in Rust.
557+
549558
## Extensions (proto2 only) {#extensions}
550559

551560
A Rust API for extensions is currently a work in progress.

content/support/cross-version-runtime-guarantee.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ compatibility window for major versions. Code generated for a major version V
4242
(full version: V.x.y) will be supported by protobuf runtimes of version V and
4343
V+1.
4444

45+
Prior to this policy, code generated for 3.22.x+ (release ~1 year prior to major
46+
version 4) will still be supported by protobuf runtimes of version 3 and 4.
47+
Users with older gencode should upgrade to the latest gencode from 3.25.x.
48+
4549
Protobuf will not support using gencode from version V with runtime &gt;= V+2
4650
and will be using a "poison pill" mechanism to fail with a clear error message
4751
when a software assembly attempts to use such a configuration.

0 commit comments

Comments
 (0)