Commit Graph

17700 Commits (main)

Author SHA1 Message Date
Protobuf Team Bot bc80135f10 Auto-generate files after cl/632314763 2024-05-10 00:30:13 +00:00
Hong Shin d071c60878 Break out idx in upb_MiniTableSub computation for clarity
PiperOrigin-RevId: 632314763
2024-05-09 17:18:24 -07:00
Protobuf Team Bot fefec68753 Internal changes/optimizations
PiperOrigin-RevId: 632294209
2024-05-09 15:54:16 -07:00
Protobuf Team Bot af1ecc0353 Add a check to ensure that the byte limit is not negative.
PiperOrigin-RevId: 632284538
2024-05-09 15:18:31 -07:00
Protobuf Team Bot eb31de3097 Auto-generate files after cl/632277936 2024-05-09 22:09:21 +00: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
Joshua Haberman 5a91d6fe5e [php] Added a unit test that bad UTF-8 is rejected in the parser.
PiperOrigin-RevId: 632274113
2024-05-09 14:42:05 -07:00
Protobuf Team Bot b51dc1b438 Auto-generate files after cl/632267379 2024-05-09 21:34:06 +00: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
Sandy Zhang f68350225f Move system_python.bzl to the correct open source folder
PiperOrigin-RevId: 632265705
2024-05-09 14:18:46 -07:00
Jie Luo 495ba7bcdb Nextgen Proto Pythonic API: “Add-on” proto for serialize/parse
- add google.protobuf.proto module
- wrap generated SerializeToString and ParseFromString to the new module:

def serialize(message: Message, deterministic: bool=None) -> bytes:
        """Return the serialized proto."""
def parse(message_class: typing.Type[Message], payload: bytes) -> Message:
        """Given a serialized proto, deserialize it into a Message."""

PiperOrigin-RevId: 632223409
2024-05-09 11:53:56 -07:00
Hong Shin 82e83ddc95 wire_format.cc: Refactor Message and Group handling into a helper func
PiperOrigin-RevId: 632191495
2024-05-09 10:21:36 -07:00
Éamonn McManus 510c1434ed Add `null` to the list of reserved words.
The previous change claimed to do this in addition to `true` and `false`, but it was not actually in the code.

To reiterate the text from the earlier change, now actually reflected entirely in the code:

> The identifiers `true`, `false`, and `null` are effectively reserved words in Java, although for some reason they are listed separately from the "keywords" in the Java Language Specification.
>
> This doesn't matter for regular fields, because a proto field called `true` will be accessed with `getTrue` and `setTrue`. But for extensions, the generated Java code will have a public static field whose name is the same as the name of the extension field, with `_` appended if the name is a reserved word. Previously there was no `_` for `true` etc, so the generated code would not compile.

This change should not affect any existing client code in Java. If someone had tried to use an extension called `true` (etc), they would have found that the generated proto code did not compile. Now it is possible to reference such an extension as `true_`.

PiperOrigin-RevId: 632174190
2024-05-09 09:30:45 -07:00
Protobuf Team Bot dbc2baf5bd Generate extension and k[FieldName]FieldNumber as constexpr int(s).
PiperOrigin-RevId: 632173946
2024-05-09 09:26:57 -07:00
Protobuf Team Bot 13caa08692 Enable textproto conformance tests for "-0" and "-0F".
-0 should be treated as distinct from 0 when deciding it is default valued for implicit presence fields.

PiperOrigin-RevId: 632162352
2024-05-09 08:46:57 -07:00
Protobuf Team Bot 1b06cefe33 Move casting functions to MessageLite and use ClassData as the uniqueness
instead of Reflection. This allows using these functions instead of
`dynamic_cast` for all generated types including LITE.

PiperOrigin-RevId: 632135009
2024-05-09 07:00:26 -07:00
Sandy Zhang 7febb4c48f Move upb/bazel/system_python.bzl (new alias file) to correct open source directory.
PiperOrigin-RevId: 631958564
2024-05-08 16:22:35 -07:00
Protobuf Team Bot b694cfa441 Clarify that the input to proto2::DynamicMessageFactory::GetPrototype should be non-null
PiperOrigin-RevId: 631938646
2024-05-08 15:16:02 -07:00
Protobuf Team Bot ec126a5069 Replace the single user of `PROTOBUF_ALIGNAS` with `alignas` and remove the now
dead macro.
This reduces the compile time cost of port_def.inc

PiperOrigin-RevId: 631886181
2024-05-08 12:27:42 -07:00
Protobuf Team Bot 64580b29c1 Expose JavaPackageDirectory and FileClassName in java/names.h
PiperOrigin-RevId: 631870244
2024-05-08 11:35:56 -07:00
Protobuf Team Bot d5b7d7a87f Remove dead feature macro.
The opt-out code was removed some time ago.

PiperOrigin-RevId: 631826723
2024-05-08 09:30:53 -07:00
Brent Shaffer 01744cccae chore(php): conformance testing for edition (#16712)
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/16712 from bshaffer:php-editions a1c41add7d
PiperOrigin-RevId: 631824623
2024-05-08 09:23:08 -07:00
Sandy Zhang b77343aa2c Add temporary alias for system_python.bzl at previous location .
This was added to protobuf_deps.bzl in cl/629786458 and no longer needs to be specified directly in WORKSPACE. However, an alias is needed to prevent users from breaking when upgrading from 26.x -> 27.x due to the obsolete load pointing to the wrong path.

This alias will be removed in a future release, tentatively 4.30.x.

PiperOrigin-RevId: 631821637
2024-05-08 09:18:42 -07:00
Protobuf Team Bot d8329b68e4 Add .to_owned(&self)->Msg functions to MsgMut and MsgView
PiperOrigin-RevId: 631686314
2024-05-08 00:54:28 -07:00
Protobuf Team Bot 6afb130dca Auto-generate files after cl/631620526 2024-05-08 02:19:22 +00:00
Eric Salo d923896299 upb: implement most of the non-universal setters
PiperOrigin-RevId: 631620526
2024-05-07 19:07:33 -07:00
Protobuf Team Bot 4d3a98c27e Auto-generate files after cl/631612923 2024-05-08 01:37:14 +00: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
Éamonn McManus 98d5bdd111 Add "reserved literals" to the list of reserved names for Java.
The identifiers `true`, `false`, and `null` are effectively reserved words in Java, although for some reason they are listed separately from the "keywords" in the Java Language Specification.

This doesn't matter for regular fields, because a proto field called `true` will be accessed with `getTrue` and `setTrue`. But for extensions, the generated Java code will have a public static field whose name is the same as the name of the extension field, with `_` appended if the name is a reserved word. Previously there was no `_` for `true` etc, so the generated code would not compile.

PiperOrigin-RevId: 631599695
2024-05-07 17:23:09 -07:00
Protobuf Team Bot 5632d8e616 Replace macro with constexpr function to reduce compile time cost of
port_def.inc usage.

PiperOrigin-RevId: 631545753
2024-05-07 14:17:33 -07:00
Sandy Zhang 94cf1e9446 Add 27.x to staleness check
PiperOrigin-RevId: 631532649
2024-05-07 13:39:43 -07:00
Protobuf Team Bot 12af9ade1d Add simple conformance test that builds the old gencode against the current runtime.
PiperOrigin-RevId: 631486123
2024-05-07 11:15:24 -07:00
Protobuf Team Bot ae17e81e42 Auto-generate files after cl/631454136 2024-05-07 16:59:23 +00: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
Protobuf Team Bot d45016a93f Internal changes to versions
PiperOrigin-RevId: 631435235
2024-05-07 08:44:48 -07:00
Protobuf Team Bot 5584c934bf Update AbstractMessageLite.addAll so that it won't throw when input is a LazyStringArrayList with byte[] elements.
Accidentally run into an error when I'm doing protoA.addAllFieldA(protoB.getMutableFieldAList())

PiperOrigin-RevId: 631257710
2024-05-06 19:11:03 -07:00
Mark Hansen c56bddd707 Add UnknownFieldSet.isEmpty
Allows callers to check if field set is empty without cloning the map

PiperOrigin-RevId: 631237925
2024-05-06 17:38:35 -07:00
Jie Luo 9de810acdc use struct instead of ctype. allows the protobuf python library to work on cpython 3.11's new wasm target [1]
For https://github.com/protocolbuffers/protobuf/pull/12212

PiperOrigin-RevId: 631237602
2024-05-06 17:35:32 -07:00
Mark Hansen d0b016fcfc Java full runtime: Avoid allocating when calling asMap on empty UnknownFieldSet
PiperOrigin-RevId: 631235442
2024-05-06 17:28:34 -07:00
Protobuf Team Bot f597991857 Return the default instance when parsing from an empty byte[].
PiperOrigin-RevId: 631213831
2024-05-06 16:05:29 -07:00
Yohei Yukawa 55592a28e7 Fix #10007: Propagate msvc-style link flags to clang-cl with Bazel
The idea here is to set the existing config "config_msvc" not only
when "msvc-cl" is specified but also when "clang-cl" is specified.

Keep in mind that clang-cl support in protobuf remains to be only
best-effort and untested for now.

PiperOrigin-RevId: 631195504
2024-05-06 15:03:58 -07:00
Sandy Zhang 4c8da99c48 Deprecate building from source with Maven to be removed in 4.28.x.
Most users should use the *pre-built* artifacts, or should build from source with Bazel instead.

PiperOrigin-RevId: 631187695
2024-05-06 14:36:12 -07:00
Protobuf Team Bot f70d90b474 Put arena cleanup nodes on a separate chunked list instead of at the ends of arena blocks.
The motivation is (a) better data locality during SerialArena::CleanupList and (b) simplification of arena layout.

PiperOrigin-RevId: 631173641
2024-05-06 13:54:56 -07:00
Jie Luo 24f27c3b88 Nextgen Proto Pythonic API: Add 'in' operator
(Second attempt. The first attempt missed ListValue)

The “in” operator will be consistent with HasField but a little different with Proto Plus.

The detail behavior of “in” operator in Nextgen

* For WKT Struct (to be consist with old Struct behavior):
    -Raise TypeError if not pass a string
    -Check if the key is in the struct.fields

* For WKT ListValue (to be consist with old behavior):
    -Check if the key is in the list_value.values

* For other messages:
    -Raise ValueError if not pass a string
    -Raise ValueError if the string is not a field
    -For Oneof: Check any field under the oneof is set
    -For has-presence field: check if set
    -For non-has-presence field (include repeated fields): raise ValueError

PiperOrigin-RevId: 631143378
2024-05-06 12:13:09 -07:00
Protobuf Team Bot e949bba22a Clean up port_def.inc by inlining BSWAP macros that are only used once.
PiperOrigin-RevId: 631130592
2024-05-06 11:35:23 -07:00
Protobuf Team Bot e03c1ce349 In SerialArenaChunk, (a) avoid recomputing offset of ids/arenas on each element access in constructor, (b) add a no-arg Layout() function for convenience, (c) fix an incorrect construction type in `new (&arena(i)) std::atomic<void*>`, where std::atomic<void*> should be std::atomic<SerialArena*>.
PiperOrigin-RevId: 631125248
2024-05-06 11:21:30 -07:00
Protobuf Team Bot 51cba7ce17 Auto-generate files after cl/631023575 2024-05-06 13:34:40 +00:00
Eric Salo 18306666b9 upb: clean up the UPB_TRACING_ENABLED code
PiperOrigin-RevId: 631023575
2024-05-06 06:22:50 -07:00
Jakob Buchgraber b6e0a48b02 Implement `IntoProxied` for repeated field setters
We modify set_<repeated_field> to accept the IntoProxied type as the value and move the value (avoid copying) whenever possible.

For UPB:
 - We fuse the arena of Repeated<T> with the parent message arena.
 - We use upb_Message_SetBaseField to set the upb_Array contained in the Repeated<T>.

For C++:
 - We generate an additional setter thunk that moves the value.
 - The move assignment operator of RepeatedField/RepeatedPtrField is specialized. In order to adhere to the layering check we need to add '#include' statements for all .proto imports to the generated thunks.pb.cc.

PiperOrigin-RevId: 631010333
2024-05-06 05:31:08 -07:00
Protobuf Team Bot 2f6e705595 Auto-generate files after cl/630517509 2024-05-03 22:57:16 +00:00