This is similar to what we did for built-in generators, and gives us the ability to create a new edition without subtley breaking generators that don't support it yet.
PiperOrigin-RevId: 586756816
- Remove _Internal accessors. They only have one caller and it's better to inline it.
- Remove redundant has bit setting. MergeFrom does it globally instead of per field.
- Reuse existing arena object. Avoids redundant calls to `GetArena()`.
- Use rhs object instead of weak instance for calling `New()`.
- Change repeated fields to use the generic MergeFrom instead of Arena::CopyConstruct.
PiperOrigin-RevId: 586680126
This caused an issue on some platforms where `protobuf/java/core/src/main/java/com/google/protobuf/java_features.proto` was getting turned into the invalid path `java/core/src/main/java/com/google/java_features.proto`.
Fixes#14862
PiperOrigin-RevId: 586527713
Users should migrate to corresponding feature accessors (e.g. FieldDescriptor.hasPresence, EnumDescriptor.isClosed) instead of deriving these based on syntax, which will break after under Editions (https://protobuf.dev/editions/overview/)
PiperOrigin-RevId: 586518687
This is functionally equivalent, but avoids a codegen change under editions where the inherited value of utf8_validation can change for non-string maps.
PiperOrigin-RevId: 586493296
Unlike Arena::CreateMessage, Arena::Create creates only the top level object
from arena even if it is arena constructalble; e.g. messages, RepeatedPtrField,
etc. This renders arenas less effective.
Instead of asking users to be aware of such nuances to use the right API for
the right type, this CL makes Arena::Create recognizes and fully supports arena
constructable types.
While extremly rare, some users try to emulate Arena::CreateMessage with
Arena::Create by passing arena parameter twice. For example,
```
auto foo = Arena::Create<Foo>(&arena, &arena); // bad
```
This pattern is not supported and will break after this change. The following
is recommended instead.
```
auto foo = Arena::CreateMessage<Foo>(&arena); // recommended
auto foo = Arena::Create<Foo>(&arena); // after this change
```
PiperOrigin-RevId: 585709990
- Avoid redundant calls to `GetArena()`.
- Only do a single call to `xxx_clear()` if needed.
- Set the oneof_case once, if needed.
- Use CopyConstruct for new objects, like we do for non-oneof Merge.
- Avoid the _Internal::mutable_xxx functions, as they are not needed anymore.
PiperOrigin-RevId: 585705944
This change names the lifetime of Mut<'a, T> and requires that T outlives 'a. The motivation for this change came up while implementing `Map<K, ProtoStr>`. The Map implementation makes it so that `V` needs to implement the `MapWithKeyOps` trait which has an associated type with a lifetime (`Value<'a>`. The lifetime bound on `T` ensures that e.g. for `MapWithKeyOps<Value<'b>=&'b ProtoStr>` `'a` outlives `'b`.
PiperOrigin-RevId: 585657154