Instead of solely emitting a forwarding header that just houses incomplete types, we opt to forward declare as-needed inside our genn'ed hpb header.
PiperOrigin-RevId: 726050002
In this CL, we add the macro UPB_EXT_PRIMITIVE.
The template specializations are practically identical sans the CppType and UpbFunc called, so we now consolidate via this macro.
Added support for uint32/64, float/double, and bool.
Getting and setting exts of ^ in hpb should all work, and fetch the proper default value as well (if provided in the .proto).
PiperOrigin-RevId: 707897721
Before this change, hpb had no way of returning repeated fields (that are extensions) -- they were incorrectly treated as pure scalars (int32 vs repeated<int32>).
We rectify this hole and now return RepeatedField<T> for a given T.
This CL also cleans up the `if constexpr` special casing we were performing inside GetExtension and delegates that to the UpbExtensionTrait.
PiperOrigin-RevId: 706789273
We introduce hpb::ExtensionRegistry::generated_registry. In the future, Parse calls will default to this being the default registry, while still being able to supply their own (if needed).
PiperOrigin-RevId: 697690765
We introduce AddExtension, which'll take an ExtensionId. From there, our helper extracts the mini_table_ext() ptr and handles the upb_ExtensionRegistry behind the scenes.
The ctor for an ExtensionRegistry has been updated to just take an arena.
Just need to supply an extension, and let us handle the rest!
PiperOrigin-RevId: 696136849
Not invoked just yet, as extant users may expect the old `GetOrPromote` pathway.
An incremental Δ for getting message extensions up to parity with proto2.
PiperOrigin-RevId: 695723050
.index() is dependent on the order specified in the .proto file.
Minitables create their own ordering, which represent the true index that we're interested in set_alias.
This can be fetched via .layout_index when we have a upb::FieldDefPtr.
PiperOrigin-RevId: 691825782
At the moment, hpb's public api solely returns Ptr<const Extension>. We'd like to support all non-msg types like int32, int64, bool etc.
These should not return a Ptr<...> but the underlying primitive itself.
We start by adding support for int32 and int64.
PiperOrigin-RevId: 691490444
Have ExtensionIdentifier have a upb_MiniTableExtension* instead of subclassing a class that is just a plain holder for a upb_MiniTableExtension* with a getter with the same name
We generally want to lean toward composition over inheritance. Without a compelling reason for inheritance, let's prefer composition for clarity, flexibility, and evolvability. Locking oneself into an inheritance hierarchy has marred many a codebase.
PiperOrigin-RevId: 689380813
Before this CL, it was only possible to get CHandles when fetching messages from a map. proto2::cpp does not have this restriction, so we patch this gap in here.
+utilize the new Emit :)
PiperOrigin-RevId: 686475508
We unify hpb's impl to utilize Protobuf's canonical printer, as opposed to a bespoke solution.
- augment hpb::Context with EmitLegacy, which keeps the $* syntax while we convert. This allows for a far simpler transitional pathway, and we can incrementally port to .Emit() as we see fit. Of course, all new calls should use .Emit().
- use the Context to wrap io::Printer and any hpb-specific info (e.g. what backend we're using)
PiperOrigin-RevId: 686198921
Similar to set_alias for singular submessages, we augment hpb with the ability to add already-allocated messages via the generated function add_alias for repeated messages.
PiperOrigin-RevId: 684136800
Similar to set_alias for singular submessages, we augment hpb with the ability to add already-allocated messages via the generated function add_alias for repeated messages.
PiperOrigin-RevId: 683269532
In certain cases, it is useful to share submessages across multiple parent messages.
proto2::cpp has a mechanism for this, so we add the hpb equivalent.
For this initial impl, we stipulate that the arenas must be exactly the same. We may explore broadening the constraint to allow for all fused arenas.
PiperOrigin-RevId: 681169537
```
hpb::Arena arena;
auto foo = hpb::CreateMessage<Foo>(arena);
foo.GetInternalArena(); // this call will now be impossible
```
Before this CL, any Proxy/Ptr could get its internal arena. This
unnecessarily leaks upb internals when they should be
interacted with via hpb::interop::upb::*.
PiperOrigin-RevId: 676038573