Commit Graph

638 Commits (main)

Author SHA1 Message Date
Sandy Zhang c99cf4bbfa Add `java` to reserved names to escape extensions to `java_`. This may break existing references to gencode for extensions named `java`.
This prevents shadowing of `java.lang` package commonly used in protobuf gencode. Existing extensions named `java` may or may not previously fail to compile depending on if the contents of their .proto result in gencode using `java.lang`. This is needed to fix `java_features.proto` lite gencode since enum gencode uses `java.lang`. Fields named `java` should already be escaped.

*Warning: This may break user code for existing protos with extensions named `java`. References to the extension should be renamed to use `java_` e.g. registry.add(GeneratedClassName.java_)*

PiperOrigin-RevId: 632508249
2024-05-10 08:49:22 -07:00
Protobuf Team Bot 37b2e3cb43 Internal changes.
PiperOrigin-RevId: 625086124
2024-04-15 14:37:15 -07:00
Dave MacLachlan b375d010bf Optimize startup be reducing selector lookup.
Move away from looking up selectors at proto initialization time to doing optimized string compares at implementation resolving time.

PiperOrigin-RevId: 623183331
2024-04-09 09:14:31 -07:00
Protobuf Team Bot 83ec410d30 Internal change
PiperOrigin-RevId: 619377672
2024-03-27 05:50:55 -07:00
Thomas Van Lenten 9f52d5e380 [ObjC] Fix issue using GPBBootstrap.h only.
GPB_ENUM_FWD_DECLARE needs `int32_t`, so add the import so GPBBootstrap.h
stands on its own without needing users to import something else.

Add another compile test file to ensure this doesn't break.

PiperOrigin-RevId: 610403337
2024-02-26 07:37:41 -08:00
Thomas Van Lenten f9731fdf73 [ObjC] Fix potential `-Wstrict-prototypes` warning.
PiperOrigin-RevId: 609718293
2024-02-23 07:14:22 -08:00
aiuto 3ab1276bbb Update Bazel references to rules_pkg to the supported file locations. (#15780)
WIP:  I want to see this pass CI first.

Fixes: #15779

3 scripted transforms:
```
  -load("@rules_pkg//:mappings.bzl", ...)
  +load("@rules_pkg//pkg:mappings.bzl", ...)
```
```
  -load("@rules_pkg//:pkg.bzl", "pkg_tar")
  +load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
```
```
  -load("@rules_pkg//:pkg.bzl", "pkg_zip")
  +load("@rules_pkg//pkg:zip.bzl", "pkg_zip")
```

Closes #15780

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/15780 from aiuto:rules_pkg a630276341
PiperOrigin-RevId: 606641398
2024-02-13 09:08:42 -08:00
Chris Kennelly 34a04c1fd5 Remove lazy=true from repeated fields.
This is currently a no-op in protoc.

PiperOrigin-RevId: 604457261
2024-02-05 15:53:12 -08:00
Thomas Van Lenten 29b4ed7289 [ObjC] Use a local to avoid warnings in 32bit builds.
CocoaPods fails spec validation for some warnings, so use a local
to avoid warnings for 64->32bit implicit conversions. This comes up
for watchOS builds.

PiperOrigin-RevId: 601849919
2024-01-26 13:19:59 -08:00
Protobuf Team Bot 7d508b41df Internal change
PiperOrigin-RevId: 599669392
2024-01-19 06:55:13 -08:00
Thomas Van Lenten 6c7c5a5d2a [ObjC] Enable editions conformance tests.
PiperOrigin-RevId: 590328722
2023-12-12 14:15:09 -08:00
Thomas Van Lenten b146d14e31 [ObjC] Improve handing of the WKT ObjC Category additions.
Include a comment in the generated header about there being helpers
in GPBWellKnowTypes.h

Generate some extra code for the WKTs that have categories to help
ensure the categories get linked so developers don't have to use
-ObjC in some cases.

PiperOrigin-RevId: 589179237
2023-12-08 10:45:35 -08:00
Thomas Van Lenten 29fca8a64b [ObjC] Add a `unpack` helper for GPBAny with extension support.
The message included could be proto2 syntax and thus have extensions.

PiperOrigin-RevId: 586991004
2023-12-01 06:26:19 -08:00
Protobuf Team Bot 1e0338b2ba [ObjC] Ensure `-[GPBMessage writeToOutputStream:]` still throws exception on flush failure
This restores the behavior of `-[GPBMessage writeToOutputStream:]` throwing an
exception if the underlying `GPBCodedOutputStream` failed to flush.

`GPBDictionary` and `GPBUnknownFieldSet` could also have theoretically thrown
exceptions from just about any method (although not for disk I/O reasons), so
this also restores that functionality by explicitly flushing before deallocating
the `GPBCodedOutputStream`.

PiperOrigin-RevId: 580207004
2023-11-07 09:33:25 -08:00
Protobuf Team Bot a2815fa13f [ObjC] Ensure -[GPBCodedOutputStream dealloc] cannot throw exceptions
If `-[GPBCodedOutputStream flush]` failed (e.g., because the filesystem
was out of space), then `-[GPBCodedOutputStream dealloc]` would throw
an exception.

`-dealloc` cannot fail, so the only thing to do in this case is to silently
swallow the exception.

PiperOrigin-RevId: 579916429
2023-11-06 12:04:29 -08:00
Thomas Van Lenten d702651e5d [ObjC] Ensure collecting delimitedData always return zero length on failure.
There was the potential for if the serialization failed, the final
release of the CodedOutputStream could flush some data back into the
return result; instead insure a zero length data is always returned
for that error case.

PiperOrigin-RevId: 579865501
2023-11-06 09:21:03 -08:00
Adam Cozzette 501ececd39 Reorganize upb file structure
This change moves almost everything in the `upb/` directory up one level, so
that for example `upb/upb/generated_code_support.h` becomes just
`upb/generated_code_support.h`. The only exceptions I made to this were that I
left `upb/cmake` and `upb/BUILD` where they are, mostly because that avoids
conflict with other files and the current locations seem reasonable for now.

The `python/` directory is a little bit of a challenge because we had to merge
the existing directory there with `upb/python/`. I made `upb/python/BUILD` into
the BUILD file for the merged directory, and it effectively loads the contents
of the other BUILD file via `python/build_targets.bzl`, but I plan to clean
this up soon.

PiperOrigin-RevId: 568651768
2023-09-26 14:38:35 -07:00
Thomas Van Lenten 6b30163526 [ObjC] Clean up enum fields when not using fwd decls.
Honor the generation option to create the minimal property for enum fields.

PiperOrigin-RevId: 568239992
2023-09-25 09:26:53 -07:00
Sandy Zhang 81068e8e8c Internal change
PiperOrigin-RevId: 566426899
2023-09-18 15:17:56 -07:00
Adam Cozzette 7286ffceb2 Merge the protobuf and upb Bazel repos
A couple weeks ago we moved upb into the protobuf Git repo, and this change
continues the merger of the two repos by making them into a single Bazel repo.
This was mostly a matter of deleting upb's WORKSPACE file and fixing up a bunch
of references to reflect the new structure.

Most of the changes are pretty mechanical, but one thing that needed more
invasive changes was the Python script for generating CMakeLists.txt,
make_cmakelists.py. The WORKSPACE file it relied on no longer exists with this
change, so I updated it to hardcode the information it needed from that file.

PiperOrigin-RevId: 564810016
2023-09-12 13:09:54 -07:00
Joshua Haberman db20f5ffc9 Shorten our license headers into an abbreviated form that references LICENSE instead of including it in full.
PiperOrigin-RevId: 564013990
2023-09-09 09:01:30 -07:00
Joshua Haberman 44bd65b2d3 Shorten our license headers into an abbreviated form that references LICENSE instead of including it in full.
PiperOrigin-RevId: 563894040
2023-09-08 18:47:26 -07:00
Joshua Haberman 200c9589c4 Shorten our license headers into an abbreviated form that references LICENSE instead of including it in full.
PiperOrigin-RevId: 563893930
2023-09-08 18:45:55 -07:00
Thomas Van Lenten 740d314166 [ObjC] Simplify root registry generation.
The the distinction in the output isn't worth it.

PiperOrigin-RevId: 556828871
2023-08-14 10:06:35 -07:00
Thomas Van Lenten ff259f71c5 [ObjC] Scrub "syntax" references and editions prep
Scrub all the objc related sources for references to "syntax"
and update them to no longer tie things accordingly.

The ObjC Protos `GPBFileDescriptor` concept still exposes the
`syntax`, but it was already marked as deprecated. This will be
removed in the future as nothing should need to look at the value.

Validate that all generation calls are on the helpers to get the
editions support from the C++ code.

PiperOrigin-RevId: 555971288
2023-08-11 09:14:48 -07:00
Jie Luo b359e5020a Lock down ctype=CORD in proto file.
ctype can not be used for none string/bytes fields. ctye=CORD can not be used for extensions. A new macro PROTOBUF_FUTURE_REMOVE_WRONG_CTYPE is added that will be flipped for our next breaking release.

PiperOrigin-RevId: 555615362
2023-08-10 12:56:26 -07:00
Thomas Van Lenten f6409bd2c4 [ObjC] Mark NSOutputStream helper as not inlinable.
With some optimizer flags, GPBCodedOutputStream results in a lot of
code bloat, for now just prevent the new helper related to
NSOutputStream from being inlined to keep that in check.

PiperOrigin-RevId: 554525631
2023-08-07 10:50:10 -07:00
Thomas Van Lenten f607b66d9f Fix typos.
They got noticed after the previous change was being submitted.

PiperOrigin-RevId: 553560211
2023-08-03 12:45:35 -07:00
Thomas Van Lenten 94a9261a28 [ObjC] Handle interruptions when writing to NSOutputStreams.
A write succeed but only write out a subset of the requested amount
of data, handle that via a helper that will loop and advance as need
to completely write out the data.

PiperOrigin-RevId: 553516360
2023-08-03 10:23:15 -07:00
Benjamin Peterson 1bee4578b8 bazel: Get rid of exec_tools. (#13401)
Bazel has removed this attribute in bazelbuild/bazel@c061e57a70.

Closes #13401

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/13401 from benjaminp:exec_tools 9e718ff0fd
PiperOrigin-RevId: 552482730
2023-07-31 08:08:39 -07:00
Thomas Van Lenten 2b0e9f7787 Invoke the pddm validations via bazel
PiperOrigin-RevId: 548687354
2023-07-17 07:51:03 -07:00
Thomas Van Lenten 6c4ab101ce Move MessageGenerator::GenerateSource over to Printer::Emit
There are whatespace changes because I couldn't get some of the
generated CPreProcessor things to line up in the exact same way.

PiperOrigin-RevId: 547188309
2023-07-11 07:54:35 -07:00
Mike Kruskal 3688ddb5b3 Internal changes
PiperOrigin-RevId: 544976965
2023-07-03 05:59:06 -07:00
Mike Kruskal ff0dd3a148 Fix objectivec test failure in Bazel 6+.
This fix works in Bazel 5 and 6, but the original `import pddm` only works in Bazel 5.  This is preventing our upgrade to Bazel 6 that will reduce our mac flakes in CI.

PiperOrigin-RevId: 543565397
2023-06-26 15:59:48 -07:00
Thomas Van Lenten 2f1938fafe Update the minimum macos to match cl/537907016
PiperOrigin-RevId: 538763399
2023-06-08 06:20:36 -07:00
Protobuf Team Bot 242771ad15 Internal change
PiperOrigin-RevId: 537790620
2023-06-05 03:45:41 -07:00
Thomas Van Lenten e50ee82feb Change indent the indent to try and stabilize the export/import.
Not really sure why things changed and started having this problem, but
cl/536414905 & cl/536708284 just keep swapping this so hopefully changing
the formatting to avoid this going forward.

PiperOrigin-RevId: 537035911
2023-06-01 08:53:15 -07:00
Protobuf Team Bot d73406a007 Auto-generate files after cl/537029283 2023-06-01 15:34:21 +00:00
Protobuf Team Bot 47f76b7a33 Minor refactor to MapSorter to avoid putting the value_type/mapped_type in the std::sort instantiation.
This allows making only a few instantiations of std::sort (one per key type) instead of one for each key-value pair.

PiperOrigin-RevId: 537029283
2023-06-01 08:24:23 -07:00
Protobuf Team Bot 02e071fe0b Auto-generate files after cl/536936386 2023-06-01 07:32:38 +00:00
Protobuf Team Bot aa9919d1f8 Internal change
PiperOrigin-RevId: 536936386
2023-06-01 00:23:53 -07:00
Protobuf Team Bot 8322f28183 Auto-generate files after cl/536934704 2023-06-01 07:17:11 +00:00
Protobuf Team Bot 917e00e393 Internal change
PiperOrigin-RevId: 536934704
2023-06-01 00:08:13 -07:00
Protobuf Team Bot df3b8feadc Auto-generate files after cl/536929770 2023-06-01 06:50:13 +00:00
Jie Luo 52dfa4b853 Update file reference for compiler/cpp/file.cc
PiperOrigin-RevId: 536929770
2023-05-31 23:38:11 -07:00
Protobuf Team Bot 39f7631f47 Auto-generate files after cl/536859974 2023-06-01 00:02:12 +00:00
Protobuf Team Bot d8901265c7 Check invalid type_id after casting it to uint32_t.
PiperOrigin-RevId: 536859974
2023-05-31 16:49:21 -07:00
Protobuf Team Bot 96c5923601 Auto-generate files after cl/536851491 2023-05-31 23:21:34 +00:00
Mike Kruskal 7971ec7629 Clarify is_packed comments.
PiperOrigin-RevId: 536851491
2023-05-31 16:12:47 -07:00
Protobuf Team Bot d5df25d965 Auto-generate files after cl/536843635 2023-05-31 22:51:28 +00:00