This change ensures that enums and enum values named NULL are correctly escaped to NULL_ in the generated C++ code,
avoiding conflicts with the NULL macro. Added a regression test case to verify the fix.
PiperOrigin-RevId: 861526129
We are absorbing its contents into other directories. This will reduce the 3:1 merge to `upb/bazel` in GitHub to 2:1 (soon to be 1:1).
PiperOrigin-RevId: 860299666
The previous CL's approach of using `__attribute__((weakref()))` was not actually behaving as expected, and the unit tests were not sufficient to catch this.
We now use inline assembly to achieve the functionality that we thought we were getting with `__attribute__((weakref()))`. From assembly, we can create a weak symbol whose value is the same as another "stub" symbol in the same file.
Unfortunately we cannot have all of our weak symbols reference a single placeholder "empty" message, due to a bug I discovered in the LLVM linker and reported in https://github.com/llvm/llvm-project/issues/167262
If and when that bug is fixed, we should be able to get optimal tree shaking behavior, even on iOS.
PiperOrigin-RevId: 831396179
To do this, we use `__attribute__((weakref()))` to weakly reference a placeholder definition for tree shaken sub-messages. This provides the same tree shaking behavior we had before, but without needing an extra indirection. If we had discovered this technique before, we would have had no reason to add the indirection in cl/640369522.
This will reduce the code size and memory overhead of any MiniTables with sub-messages in them, because we no longer need an extra `void*` per sub-message field to store the extra indirect pointer.
It also should improve efficiency a bit since there is one fewer indirection when recursing into a sub-message field.
PiperOrigin-RevId: 829022414
This CL deprecates the hpb::Parse overload that returns absl::StatusOr<T>. Instead, prefer hpb::Parse -> hpb::StatusOr<T>.
String aliasing via upb is allow plumbed through with this CL.
PiperOrigin-RevId: 808732870
If a repeated field is empty, upb_Array is nullptr.
Repeated string and message fields already have similar checks. This bug only
affects empty repeated scalar fields.
PiperOrigin-RevId: 800474430
During our migration, we merely aliased `hpb::Arena` to `upb::Arena` (upb's C++ RAII wrapper for `upb_Arena`).
The alias has served us well, but it's now time to transition to a class that'll support our multibackend goals. Henceforth, `hpb::Arena` shall contain an arena based on the SELECTED backend (upb, cpp).
If the underlying upb arena needs to be accessed, `arena.ptr()` will no longer work; one must go through `hpb::interop::upb::UnwrapArena`.
If the backend is upb, the arena also has support for `.Fuse` and `.IsFused`.
PiperOrigin-RevId: 774808755
hpb::Arena can't take init blocks right now, but soon should be able to, since both backends {upb, cpp} support it. We'll re-enable then.
PiperOrigin-RevId: 772593594
We expunge the emission of the ExtensionIdentifier in the cc and `inline constexpr` it in the .h.
The extension number is fed into the constexpr ExtensionIdentifier ctor and now the id can be requested at compile time (e.g. constexpr auto extension_number = hpb::ExtensionNumber(your_extension_name_here)).
PiperOrigin-RevId: 740749472
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