Skip to content

Commit

Permalink
Merge branch 'protocolbuffers:main' into cmake_absl
Browse files Browse the repository at this point in the history
  • Loading branch information
mkruskal-google committed Apr 15, 2022
2 parents b176d7b + 82d04fa commit 72c6de8
Show file tree
Hide file tree
Showing 54 changed files with 382 additions and 226 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Stack Overflow is also a useful if unofficial resource https://stackoverflow.com
-->

**What version of protobuf and what language are you using?**
Version: master/v3.6.0/v3.5.0 etc.
Version: main/v3.6.0/v3.5.0 etc.
Language: C++/Java/Python/C#/Ruby/PHP/Objective-C/Javascript

**What operating system (Linux, Windows, ...) and version?**
Expand Down
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ conforming.

## Contributing Process

Most pull requests should go to the master branch and the change will be
Most pull requests should go to the main branch and the change will be
included in the next major/minor version release (e.g., 3.6.0 release). If you
need to include a bug fix in a patch release (e.g., 3.5.2), make sure it’s
already merged to master, and then create a pull request cherry-picking the
commits from master branch to the release branch (e.g., branch 3.5.x).
already merged to main, and then create a pull request cherry-picking the
commits from main branch to the release branch (e.g., branch 3.5.x).

For each pull request, a protobuf team member will be assigned to review the
pull request. For minor cleanups, the pull request may be merged right away
Expand Down Expand Up @@ -96,9 +96,9 @@ the final release.
of inactivity.
* Maintain clean commit history and use meaningful commit messages. PRs with
messy commit history are difficult to review and won't be merged. Use rebase
-i upstream/master to curate your commit history and/or to bring in latest
changes from master (but avoid rebasing in the middle of a code review).
* Keep your PR up to date with upstream/master (if there are merge conflicts,
-i upstream/main to curate your commit history and/or to bring in latest
changes from main (but avoid rebasing in the middle of a code review).
* Keep your PR up to date with upstream/main (if there are merge conflicts,
we can't really merge your change).
* All tests need to be passing before your change can be merged. We recommend
you run tests locally before creating your PR to catch breakages early on.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ page, check out the maven repo here:
[https://repo1.maven.org/maven2/com/google/protobuf/protoc/](https://repo1.maven.org/maven2/com/google/protobuf/protoc/)

These pre-built binaries are only provided for released versions. If you want
to use the github master version at HEAD, or you need to modify protobuf code,
to use the github main version at HEAD, or you need to modify protobuf code,
or you are using C++, it's recommended to build your own protoc binary from
source.

Expand Down
4 changes: 2 additions & 2 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This directory contains benchmarking schemas and data sets that you
can use to test a variety of performance scenarios against your
protobuf language runtime. If you are looking for performance
numbers of officially supported languages, see [Protobuf Performance](
https://github.com/protocolbuffers/protobuf/blob/master/docs/performance.md).
https://github.com/protocolbuffers/protobuf/blob/main/docs/performance.md).

## Prerequisite

Expand Down Expand Up @@ -61,7 +61,7 @@ PHP benchmark's requirement is the same as PHP protobuf's requirements. The benc
include PHP protobuf's src and build the c extension if required.

### Node.js
Node.js benchmark need [node](https://nodejs.org/en/)(higher than V6) and [npm](https://www.npmjs.com/) package manager installed. This benchmark is using the [benchmark](https://www.npmjs.com/package/benchmark) framework to test, which needn't to manually install. And another prerequisite is [protobuf js](https://github.com/protocolbuffers/protobuf/tree/master/js), which needn't to manually install either
Node.js benchmark need [node](https://nodejs.org/en/)(higher than V6) and [npm](https://www.npmjs.com/) package manager installed. This benchmark is using the [benchmark](https://www.npmjs.com/package/benchmark) framework to test, which needn't to manually install. And another prerequisite is [protobuf js](https://github.com/protocolbuffers/protobuf/tree/main/js), which needn't to manually install either

### C#
The C# benchmark code is built as part of the main Google.Protobuf
Expand Down
2 changes: 1 addition & 1 deletion cmake/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Or you can use git to clone from protobuf git repository.
C:\Path\to> mkdir src & cd src
C:\Path\to\src> git clone -b [release_tag] https://github.com/protocolbuffers/protobuf.git

Where *[release_tag]* is a git tag like *v3.0.0-beta-1* or a branch name like *master*
Where *[release_tag]* is a git tag like *v3.0.0-beta-1* or a branch name like *main*
if you want to get the latest code.

Go to the project folder:
Expand Down
4 changes: 2 additions & 2 deletions conformance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ Testing other Protocol Buffer implementations
To run these tests against a new Protocol Buffers implementation, write a
program in your language that uses the protobuf implementation you want
to test. This program should implement the testing protocol defined in
[conformance.proto](https://github.com/protocolbuffers/protobuf/blob/master/conformance/conformance.proto).
[conformance.proto](https://github.com/protocolbuffers/protobuf/blob/main/conformance/conformance.proto).
This is designed to be as easy as possible: the C++ version is only
150 lines and is a good example for what this program should look like
(see [conformance_cpp.cc](https://github.com/protocolbuffers/protobuf/blob/master/conformance/conformance_cpp.cc)).
(see [conformance_cpp.cc](https://github.com/protocolbuffers/protobuf/blob/main/conformance/conformance_cpp.cc)).
The program only needs to be able to read from stdin and write to stdout.

Portability
Expand Down
2 changes: 1 addition & 1 deletion csharp/Google.Protobuf.Tools.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<version>3.20.1-rc1</version>
<authors>Google Inc.</authors>
<owners>protobuf-packages</owners>
<licenseUrl>https://github.com/protocolbuffers/protobuf/blob/master/LICENSE</licenseUrl>
<licenseUrl>https://github.com/protocolbuffers/protobuf/blob/main/LICENSE</licenseUrl>
<projectUrl>https://github.com/protocolbuffers/protobuf</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<releaseNotes>Tools for Protocol Buffers</releaseNotes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ namespace Google.Protobuf.Benchmarks
/// Benchmark for serializing and deserializing of standard datasets that are also
/// measured by benchmarks in other languages.
/// Over time we may wish to test the various different approaches to serialization and deserialization separately.
/// See https://github.com/protocolbuffers/protobuf/blob/master/benchmarks/README.md
/// See https://github.com/protocolbuffers/protobuf/blob/master/docs/performance.md
/// See https://github.com/protocolbuffers/protobuf/blob/main/benchmarks/README.md
/// See https://github.com/protocolbuffers/protobuf/blob/main/docs/performance.md
/// </summary>
[MemoryDiagnoser]
public class GoogleMessageBenchmark
Expand Down
2 changes: 0 additions & 2 deletions csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,6 @@ public void AddEntriesFrom_CodedInputStream_MissingKey()
output.WriteString("the_value");
output.Flush();

Console.WriteLine(BitConverter.ToString(memoryStream.ToArray()));

var field = new MapField<string, string>();
var mapCodec = new MapField<string, string>.Codec(FieldCodec.ForString(keyTag, ""), FieldCodec.ForString(valueTag, ""), 10);
var input = new CodedInputStream(memoryStream.ToArray());
Expand Down
2 changes: 1 addition & 1 deletion docs/implementing_proto3_presence.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Presence tracking was added to proto3 in response to user feedback, both from
inside Google and [from open-source
users](https://github.com/protocolbuffers/protobuf/issues/1606). The [proto3
wrapper
types](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/wrappers.proto)
types](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/wrappers.proto)
were previously the only supported presence mechanism for proto3. Users have
pointed to both efficiency and usability issues with the wrapper types.

Expand Down
2 changes: 1 addition & 1 deletion docs/jvm_aot.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Ahead Of Time (AOT) compilation build tools such as those provided by [GraalVM's
Protobuf for the JVM uses reflection and some of its target classes are not possible to determine in advance.
Historically, there were good reasons to use reflection based on APIs that were published effectively requiring them, and this situation is unlikely to change.

[The Lite version of protobuf for the JVM](https://github.com/protocolbuffers/protobuf/blob/master/java/lite.md)
[The Lite version of protobuf for the JVM](https://github.com/protocolbuffers/protobuf/blob/main/java/lite.md)
avoids reflection and may be better suited for use with AOT compilation tooling. This Lite version was originally targeted for use on Android which has similar AOT compilation
goals as GraalVM's native-image tool.

Expand Down
7 changes: 7 additions & 0 deletions docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,10 @@ with info about your project (name and website) so we can add an entry for you.
* Website: https://github.com/yeqown/protoc-gen-fieldmask
* Extension: 1142

1. Google Gnostic
* Website: https://github.com/google/gnostic
* Extension: 1143

1. Protoc-gen-go-micro
* Website: https://github.com/unistack-org/protoc-gen-go-micro
* Extension: 1144
2 changes: 1 addition & 1 deletion docs/performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,4 @@ This table contains the results of three separate languages:
</tr>
</tbody></table>

\* The cpp performance can be improved by using [tcmalloc](https://gperftools.github.io/gperftools/tcmalloc.html), please follow the (instruction)[https://github.com/protocolbuffers/protobuf/blob/master/benchmarks/README.md] to link with tcmalloc to get the faster result.
\* The cpp performance can be improved by using [tcmalloc](https://gperftools.github.io/gperftools/tcmalloc.html), please follow the (instruction)[https://github.com/protocolbuffers/protobuf/blob/main/benchmarks/README.md] to link with tcmalloc to get the faster result.
4 changes: 2 additions & 2 deletions examples/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
#
# http_archive(
# name = "com_google_protobuf",
# strip_prefix = "protobuf-master",
# urls = ["https://github.com/protocolbuffers/protobuf/archive/master.zip"],
# strip_prefix = "protobuf-main",
# urls = ["https://github.com/protocolbuffers/protobuf/archive/main.zip"],
# )
local_repository(
name = "com_google_protobuf",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private static MessageInfo convert(Class<?> messageType, Descriptor messageDescr
* <p>This class is thread-safe.
*/
// <p>The code is adapted from the C++ implementation:
// https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/compiler/java/java_helpers.h
// https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/compiler/java/java_helpers.h
static class IsInitializedCheckAnalyzer {

private final Map<Descriptor, Boolean> resultCache =
Expand Down
4 changes: 2 additions & 2 deletions java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.1.1-android</version>
<version>31.1-android</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava-testlib</artifactId>
<version>30.1.1-android</version>
<version>31.1-android</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ a pre-built binary from [https://github.com/protocolbuffers/protobuf/releases](h

If you want, you can compile `protoc` from source instead. To do this
follow the instructions in [the top-level
README](https://github.com/protocolbuffers/protobuf/blob/master/src/README.md).
README](https://github.com/protocolbuffers/protobuf/blob/main/src/README.md).

Once you have `protoc` compiled, you can run the tests provided along with our project to examine whether it can run successfully. In order to do this, you should download the Protocol Buffer source code from the release page with the link above. Then extract the source code and navigate to the folder named `js` containing a `package.json` file and a series of test files. In this folder, you can run the commands below to run the tests automatically.

Expand Down Expand Up @@ -129,7 +129,7 @@ The syntax of the `--js_out` flag is:
Where `OPTIONS` are separated by commas. Options are either `opt=val` or
just `opt` (for options that don't take a value). The available options
are specified and documented in the `GeneratorOptions` struct in
[src/google/protobuf/compiler/js/js_generator.h](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/compiler/js/js_generator.h#L53).
[src/google/protobuf/compiler/js/js_generator.h](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/compiler/js/js_generator.h#L53).

Some examples:

Expand Down
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/protocolbuffers/protobuf/tree/master/js"
"url": "https://github.com/protocolbuffers/protobuf/tree/main/js"
},
"author": "Google Protocol Buffers Team",
"license": "BSD-3-Clause"
Expand Down
2 changes: 1 addition & 1 deletion kokoro/docs/publish-python.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Adapted from https://github.com/googleapis/google-cloud-python/blob/master/.kokoro/publish-docs.sh
# Adapted from https://github.com/googleapis/google-cloud-python/blob/main/.kokoro/publish-docs.sh

set -eo pipefail

Expand Down
2 changes: 1 addition & 1 deletion kokoro/docs/trampoline.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copied from https://github.com/googleapis/google-cloud-python/blob/master/.kokoro/trampoline.sh
# Copied from https://github.com/googleapis/google-cloud-python/blob/main/.kokoro/trampoline.sh

set -eo pipefail

Expand Down
2 changes: 1 addition & 1 deletion kokoro/linux/aarch64/test_java_aarch64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ kokoro/linux/aarch64/dockcross_helpers/run_dockcross_manylinux2014_aarch64.sh ko

# the command that will be used to build and test java under an emulator
# * IsValidUtf8Test and DecodeUtf8Test tests are being skipped because that take very long under an emulator.
TEST_JAVA_COMMAND="mvn --batch-mode -DskipTests install && mvn --batch-mode -Dtest='**/*Test, !**/*IsValidUtf8Test, !**/*DecodeUtf8Test' -DfailIfNoTests=false surefire:test"
TEST_JAVA_COMMAND="mvn --batch-mode -DskipTests install && mvn --batch-mode -Dtest='**/*Test, !**/*IsValidUtf8Test, !**/*DecodeUtf8Test' -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false surefire:test"

# use an actual aarch64 docker image (with a real aarch64 java and maven) to run build & test protobuf java under an emulator
# * mount the protobuf root as /work to be able to access the crosscompiled files
Expand Down
4 changes: 2 additions & 2 deletions objectivec/GPBCodedInputStream.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
GPBNSStringifySymbol(GPBCodedInputStreamErrorDomain);

// Matching:
// https://github.com/protocolbuffers/protobuf/blob/master/java/core/src/main/java/com/google/protobuf/CodedInputStream.java#L62
// https://github.com/protocolbuffers/protobuf/blob/main/java/core/src/main/java/com/google/protobuf/CodedInputStream.java#L62
// private static final int DEFAULT_RECURSION_LIMIT = 100;
// https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/io/coded_stream.cc#L86
// https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/io/coded_stream.cc#L86
// int CodedInputStream::default_recursion_limit_ = 100;
static const NSUInteger kDefaultRecursionLimit = 100;

Expand Down
12 changes: 6 additions & 6 deletions php/ext/google/protobuf/names.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ const char *const kReservedNames[] = {
"global", "goto", "insteadof", "interface", "isset",
"list", "match", "namespace", "new", "object",
"or", "parent", "print", "private", "protected",
"public", "require", "require_once", "return", "self",
"static", "switch", "throw", "trait", "try",
"unset", "use", "var", "while", "xor",
"yield", "int", "float", "bool", "string",
"true", "false", "null", "void", "iterable",
NULL};
"public", "readonly", "require", "require_once", "return",
"self", "static", "switch", "throw", "trait",
"try", "unset", "use", "var", "while",
"xor", "yield", "int", "float", "bool",
"string", "true", "false", "null", "void",
"iterable", NULL};

bool is_reserved_name(const char* name) {
int i;
Expand Down
11 changes: 6 additions & 5 deletions php/src/Google/Protobuf/Internal/GPBUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,12 @@ public static function getClassNamePrefix(
"include"=>0, "include_once"=>0, "instanceof"=>0, "insteadof"=>0,
"interface"=>0, "isset"=>0, "list"=>0, "match"=>0, "namespace"=>0,
"new"=>0, "or"=>0, "parent"=>0, "print"=>0, "private"=>0,
"protected"=>0,"public"=>0, "require"=>0, "require_once"=>0,
"return"=>0, "self"=>0, "static"=>0, "switch"=>0, "throw"=>0,
"trait"=>0, "try"=>0,"unset"=>0, "use"=>0, "var"=>0, "while"=>0,
"xor"=>0, "yield"=>0, "int"=>0, "float"=>0, "bool"=>0, "string"=>0,
"true"=>0, "false"=>0, "null"=>0, "void"=>0, "iterable"=>0
"protected"=>0,"public"=>0, "readonly" => 0,"require"=>0,
"require_once"=>0,"return"=>0, "self"=>0, "static"=>0, "switch"=>0,
"throw"=>0,"trait"=>0, "try"=>0,"unset"=>0, "use"=>0, "var"=>0,
"while"=>0,"xor"=>0, "yield"=>0, "int"=>0, "float"=>0, "bool"=>0,
"string"=>0,"true"=>0, "false"=>0, "null"=>0, "void"=>0,
"iterable"=>0
);

if (array_key_exists(strtolower($classname), $reserved_words)) {
Expand Down
18 changes: 18 additions & 0 deletions php/tests/GeneratedClassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,18 @@ public function testLegacyTypehintWithNestedEnums()
$this->legacyEnum(new TestLegacyMessage\NestedEnum);
}

public function testLegacyReadOnlyMessage()
{
$this->assertTrue(class_exists('\Upper\READONLY'));
$this->assertTrue(class_exists('\Lower\readonly'));
}

public function testLegacyReadOnlyEnum()
{
$this->assertTrue(class_exists('\Upper_enum\READONLY'));
$this->assertTrue(class_exists('\Lower_enum\readonly'));
}

private function legacyEnum(TestLegacyMessage_NestedEnum $enum)
{
// If we made it here without a PHP Fatal error, the typehint worked
Expand Down Expand Up @@ -939,6 +951,7 @@ public function testPrefixForReservedWords()
$m = new \Lower\PBprivate();
$m = new \Lower\PBprotected();
$m = new \Lower\PBpublic();
$m = new \Lower\PBreadonly();
$m = new \Lower\PBrequire();
$m = new \Lower\PBrequire_once();
$m = new \Lower\PBreturn();
Expand Down Expand Up @@ -1019,6 +1032,7 @@ public function testPrefixForReservedWords()
$m = new \Upper\PBPRIVATE();
$m = new \Upper\PBPROTECTED();
$m = new \Upper\PBPUBLIC();
$m = new \Upper\PBREADONLY();
$m = new \Upper\PBREQUIRE();
$m = new \Upper\PBREQUIRE_ONCE();
$m = new \Upper\PBRETURN();
Expand Down Expand Up @@ -1100,6 +1114,7 @@ public function testPrefixForReservedWords()
$m = new \Lower_enum\PBprotected();
$m = new \Lower_enum\PBpublic();
$m = new \Lower_enum\PBrequire();
$m = new \Lower_enum\PBreadonly();
$m = new \Lower_enum\PBrequire_once();
$m = new \Lower_enum\PBreturn();
$m = new \Lower_enum\PBself();
Expand Down Expand Up @@ -1179,6 +1194,7 @@ public function testPrefixForReservedWords()
$m = new \Upper_enum\PBPRIVATE();
$m = new \Upper_enum\PBPROTECTED();
$m = new \Upper_enum\PBPUBLIC();
$m = new \Upper_enum\PBREADONLY();
$m = new \Upper_enum\PBREQUIRE();
$m = new \Upper_enum\PBREQUIRE_ONCE();
$m = new \Upper_enum\PBRETURN();
Expand Down Expand Up @@ -1283,6 +1299,7 @@ public function testPrefixForReservedWords()
$m = \Lower_enum_value\NotAllowed::iterable;
$m = \Lower_enum_value\NotAllowed::parent;
$m = \Lower_enum_value\NotAllowed::self;
$m = \Lower_enum_value\NotAllowed::readonly;

$m = \Upper_enum_value\NotAllowed::PBABSTRACT;
$m = \Upper_enum_value\NotAllowed::PBAND;
Expand Down Expand Up @@ -1363,6 +1380,7 @@ public function testPrefixForReservedWords()
$m = \Upper_enum_value\NotAllowed::ITERABLE;
$m = \Upper_enum_value\NotAllowed::PARENT;
$m = \Upper_enum_value\NotAllowed::SELF;
$m = \Upper_enum_value\NotAllowed::READONLY;

$this->assertTrue(true);
}
Expand Down
1 change: 1 addition & 0 deletions php/tests/proto/test_reserved_enum_lower.proto
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ enum print { ZERO51 = 0; }
enum private { ZERO52 = 0; }
enum protected { ZERO53 = 0; }
enum public { ZERO54 = 0; }
enum readonly { ZERO80 = 0; }
enum require { ZERO55 = 0; }
enum require_once { ZERO56 = 0; }
enum return { ZERO57 = 0; }
Expand Down
Loading

0 comments on commit 72c6de8

Please sign in to comment.