Commit Graph

1777 Commits (main)

Author SHA1 Message Date
Hong Shin 0645439efa Introduce upb_EncodeStatus_String and upb_DecodeStatus_String
Wrapper languages can now use these helpers to get human-friendly
error codes as opposed to manually re-mapping.

PiperOrigin-RevId: 634112262
2024-05-15 16:30:37 -07:00
pbatg 30a40eefe5 Fixed broken link in upb README.md (#16717)
I noticed this link was broken.  I'm not familiar with the project, but the code in https://github.com/protocolbuffers/protobuf/tree/main/upb/python does appear to import upb headers, so I think it's the right URL.

Closes #16717

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/16717 from pbatg:patch-1 c9e654308d
PiperOrigin-RevId: 633589882
2024-05-14 08:34:33 -07:00
Eric Salo f93565c20c upb: publish and start using the new non-universal setters out in the wild
PiperOrigin-RevId: 632663127
2024-05-10 19:09:28 -07:00
Hong Shin d071c60878 Break out idx in upb_MiniTableSub computation for clarity
PiperOrigin-RevId: 632314763
2024-05-09 17:18:24 -07:00
Éamonn McManus b5fc2735e9 In `upb_MiniTableExtension_GetSubMessage`, return NULL for non-messages.
This parallels the logic in `upb_MiniTable_SubMessage`.

PiperOrigin-RevId: 632277936
2024-05-09 14:57:53 -07:00
Eric Salo 6245733655 upb: remove the unused (upb_MiniTable*) arg from upb_Message_SetMessage()
PiperOrigin-RevId: 632267379
2024-05-09 14:22:25 -07:00
Eric Salo d923896299 upb: implement most of the non-universal setters
PiperOrigin-RevId: 631620526
2024-05-07 19:07:33 -07:00
Eric Salo 65821a67d6 upb: finish cleaning up message/accessors.h and message/internal/accessors.h
PiperOrigin-RevId: 631612923
2024-05-07 18:25:25 -07:00
Hong Shin 6ccda4d2b5 Add upb_Message_ClearOneof (and retain upb_Message_WhichOneofFieldNumber)
upb users currently need to manually fetch a oneof field in order to clear it.
In this CL, we add a convenience method to do that in one fell swoop.

PiperOrigin-RevId: 631454136
2024-05-07 09:47:27 -07:00
Eric Salo 18306666b9 upb: clean up the UPB_TRACING_ENABLED code
PiperOrigin-RevId: 631023575
2024-05-06 06:22:50 -07:00
Eric Salo aa70a3576b upb: clean up message/accessors.h and message/internal/accessors.h
PiperOrigin-RevId: 630466865
2024-05-03 12:35:57 -07:00
Protobuf Team Bot d3b2fc52a4 Auto-generate files after cl/630090538 2024-05-02 17:02:37 +00:00
Protobuf Team Bot c9eeb1c8a7 Internal changes.
PiperOrigin-RevId: 630090538
2024-05-02 09:50:54 -07:00
Éamonn McManus b4f4f8ef65 Automated rollback of commit 7a09c4569b.
PiperOrigin-RevId: 629808114
2024-05-01 12:53:10 -07:00
Hong Shin 7a09c4569b Add upb_Message_ClearOneof
upb users currently need to manually fetch a oneof field in order to clear it.
In this CL, we add a convenience method to do that in one fell swoop.

PiperOrigin-RevId: 629782904
2024-05-01 11:32:26 -07:00
Protobuf Team Bot 12a828c700 Add UPB_ASSUME(!IsExtension) on GetMutableMessage.
This function is UB to call on an extension field.

PiperOrigin-RevId: 629701038
2024-05-01 05:56:21 -07:00
Hong Shin 52c12a6f92 Automated rollback of commit 208cae7fd7.
PiperOrigin-RevId: 629424223
2024-04-30 08:43:35 -07:00
Hong Shin 208cae7fd7 Internal Change
PiperOrigin-RevId: 629226391
2024-04-29 16:50:25 -07:00
Éamonn McManus 501067aa80 Expose `MiniDescriptorEncode` for `FieldDefPtr`.
We already expose equivalent methods for `MessageDefPtr` and `EnumDefPtr`.

PiperOrigin-RevId: 629150393
2024-04-29 12:33:09 -07:00
Protobuf Team Bot 62f2b143d5 Change the arena.hpp ::Fuse return type to bool to surface whether the fuse failed.
PiperOrigin-RevId: 628161481
2024-04-25 12:48:33 -07:00
Hong Shin e0fc566596 Ensure the appropriate upb functions taking non-const pointers assert that the message is not frozen.
Fixes message/promote.c and internal/extension.c.

PiperOrigin-RevId: 628095780
2024-04-25 09:16:36 -07:00
Eric Salo 8be1312b3c upb: fix Dart empty imports
PiperOrigin-RevId: 627794151
2024-04-24 11:30:43 -07:00
Hong Shin 5b5db6666e Check IsFrozen for internal/message.c and reflection/message.c
PiperOrigin-RevId: 627531912
2024-04-23 16:05:17 -07:00
Hong Shin bd9f211f97 Remove IsFrozen checks from upb/conformance
PiperOrigin-RevId: 627492449
2024-04-23 13:46:47 -07:00
Hong Shin bceb7f597f Check IsFrozen for message/copy.c, experimental_jspb/decode.c, and json/decode.c
PiperOrigin-RevId: 627468915
2024-04-23 12:27:08 -07:00
Hong Shin 0e3650c29c Add IsFrozen checks to conformance_upb and upb_js
PiperOrigin-RevId: 627419894
2024-04-23 09:56:27 -07:00
Hong Shin 335edb909f update decode_fast.c to assert that non-const messages are not frozen
PiperOrigin-RevId: 627393634
2024-04-23 08:20:58 -07:00
Joshua Haberman 37e484a0aa Replace direct access to MiniTable subs with calls to the encapsulated functions.
PiperOrigin-RevId: 626485595
2024-04-19 15:31:49 -07:00
Protobuf Team Bot 6afdd5a135 Auto-generate files after cl/625815212 2024-04-17 22:09:39 +00:00
Mike Kruskal e5502c746e Removed merged features from the edition defaults IR.
All of this information is still available by merging fixed_features and overridable_features.  This new split will make validation easier for runtimes that need to do dynamic builds.

PiperOrigin-RevId: 625815212
2024-04-17 14:58:17 -07:00
Mike Kruskal db5814e4ff Use newly split feature defaults in plugins and runtimes.
The new fields fixed_features and overridable_features can be simply merged to recover the old aggregate defaults.  By splitting them though, plugins and runtimes get some extra information about lifetimes for enforcement.

PiperOrigin-RevId: 625527117
2024-04-16 19:18:40 -07:00
Joshua Haberman b9b735cc73 Internal change
PiperOrigin-RevId: 625502066
2024-04-16 17:28:30 -07:00
Mike Kruskal ea81024ddf Refactor editions infrastructure to a top-level directory.
The only public target here is the edition defaults helper macro, which can be used by external runtimes and plugins.  None of this code is C++-specific though, and should be organized higher up.  Appropriate aliases are also placed at the top level for public targets

PiperOrigin-RevId: 625392504
2024-04-16 11:13:19 -07:00
Eric Salo bb3e50e15e upb: implement Dart public imports
PiperOrigin-RevId: 625324587
2024-04-16 07:32:34 -07:00
Protobuf Team Bot a5be8bdb9f Auto-generate files after cl/625084569 2024-04-15 21:45:12 +00:00
Eric Salo 8d025c08ff upb: implement named imports in Dart
PiperOrigin-RevId: 624186848
2024-04-12 08:29:17 -07:00
Mike Kruskal 7d87a1780a Hook up staleness tests to non-bootstrap edition defaults
PiperOrigin-RevId: 623936729
2024-04-11 14:23:41 -07:00
Protobuf Team Bot 2322a8720f Auto-generate files after cl/623529512 2024-04-10 17:23:17 +00:00
Mike Kruskal da651cd3c2 Restore legacy edition enum value
PiperOrigin-RevId: 623529512
2024-04-10 10:11:34 -07:00
Protobuf Team Bot b8bb56df4c Change Rust-upb to use upb_Encode and upb_Decode directly, instead of going through the upb C gencode.
PiperOrigin-RevId: 623474125
2024-04-10 06:27:06 -07:00
Protobuf Team Bot ac32c97fbf Auto-generate files after cl/623355801 2024-04-10 03:30:05 +00:00
Eric Salo 9118be944d upb: extension/basefield setters are now public functions
PiperOrigin-RevId: 623355801
2024-04-09 20:18:28 -07:00
Éamonn McManus 0013736b04 Fix typo in `kUpb_EncodeOption_SkipUnkown`.
It is about encoding, not printing.

PiperOrigin-RevId: 622979373
2024-04-08 16:14:57 -07:00
Hong Shin 09529fe018 Update reader.c to initialize i inside loop
PiperOrigin-RevId: 622958098
2024-04-08 14:52:23 -07:00
Eric Salo 52aa23f3fc upb: reuse upb_Message_Internal buffer after a upb_Message_Clear()
PiperOrigin-RevId: 622913413
2024-04-08 12:00:57 -07:00
Eric Salo bcd44f65c8 upb: upb_MiniTable_MessageFieldIsLinked() -> upb_MiniTable_FieldIsLinked()
PiperOrigin-RevId: 622902387
2024-04-08 11:18:41 -07:00
Eric Salo 818da99549 upb: replace upb_MiniDescriptor_BuildEnum() with upb_MiniTableEnum_Build()
PiperOrigin-RevId: 622879398
2024-04-08 10:07:30 -07:00
Eric Salo 3d21bc26c9 upb: define kUpb_CompareOption_IncludeUnknownFields flag for upb_Message_IsEqual()
PiperOrigin-RevId: 622335300
2024-04-05 18:44:54 -07:00
Mike Kruskal 29c69ff00b Fix text-format delimited field handling
This updates all our text parsers and serializers to better handle tag-delimited fields under editions.  Under proto2, groups were the only tag-delimited fields possible, and the group name (i.e. the message type) was guaranteed to be unique.  Text-format and various generators used this instead of the synthetic field name (lower-cased group name) to represent these fields.

Under editions, we've removed group syntax and allowed any message field to be tag-delimited.  This breaks those cases when adding new tag-delimited fields where the message type might not be unique or correspond to the field name.  Code generators have already been fixed to treat "group-like" fields using the old behavior, and treat new fields like any other sub-message.

This change addresses the text-format issue.  Text parsers will accept *either* the type or field name for "group-like" fields, and only the field name for every other message field.  Text serializers will continue to emit the message name for "group-like" fields, but also use the field name for everything else.

This creates some awkward capitalization behavior for fields that happen to *look* like proto2 groups, but it won't lead to any conflicts or invalid encodings.  A feature will likely be added to edition 2024 to allow for migration off this legacy behavior.

PiperOrigin-RevId: 622260327
2024-04-05 13:08:43 -07:00
Protobuf Team Bot d5a435fb4b Rename 'length delimited' to 'length prefixed'
PiperOrigin-RevId: 621597812
2024-04-03 12:13:54 -07:00