Automated rollback of commit 2b86c3d9ed.

PiperOrigin-RevId: 603166021
pull/15666/head
Protobuf Team Bot 10 months ago committed by Copybara-Service
parent 8135fca851
commit 690f100a66
  1. 4
      src/google/protobuf/compiler/java/file.cc
  2. 36
      src/google/protobuf/compiler/java/helpers.cc
  3. 24
      src/google/protobuf/compiler/versions.cc
  4. 6
      src/google/protobuf/compiler/versions.h

@ -519,13 +519,13 @@ static void GenerateSibling(
printer.Print( printer.Print(
"// Generated by the protocol buffer compiler. DO NOT EDIT!\n" "// Generated by the protocol buffer compiler. DO NOT EDIT!\n"
"// source: $filename$\n", "// source: $filename$\n"
"\n",
"filename", descriptor->file()->name()); "filename", descriptor->file()->name());
if (opensource_runtime) { if (opensource_runtime) {
printer.Print("// Protobuf Java Version: $protobuf_java_version$\n", printer.Print("// Protobuf Java Version: $protobuf_java_version$\n",
"protobuf_java_version", PROTOBUF_JAVA_VERSION_STRING); "protobuf_java_version", PROTOBUF_JAVA_VERSION_STRING);
} }
printer.Print("\n");
if (!java_package.empty()) { if (!java_package.empty()) {
printer.Print( printer.Print(
"package $package$;\n" "package $package$;\n"

@ -87,21 +87,27 @@ void PrintEnumVerifierLogic(
void PrintGencodeVersionValidator(io::Printer* printer, bool oss_runtime, void PrintGencodeVersionValidator(io::Printer* printer, bool oss_runtime,
absl::string_view java_class_name) { absl::string_view java_class_name) {
const auto& version = GetProtobufJavaVersion(oss_runtime); if (oss_runtime) {
printer->Print( const auto& version = GetProtobufJavaVersion();
"com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(\n" printer->Print(
" com.google.protobuf.RuntimeVersion.RuntimeDomain.$domain$,\n" "com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(\n"
" $major$,\n" " com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC,\n"
" $minor$,\n" " $major$,\n"
" $patch$,\n" " $minor$,\n"
" $suffix$,\n" " $patch$,\n"
" $location$);\n", " $suffix$,\n"
"domain", oss_runtime ? "PUBLIC" : "GOOGLE_INTERNAL", "major", " $location$);\n",
absl::StrCat("/* major= */ ", version.major()), "minor", "major", absl::StrCat("/* major= */ ", version.major()), "minor",
absl::StrCat("/* minor= */ ", version.minor()), "patch", absl::StrCat("/* minor= */ ", version.minor()), "patch",
absl::StrCat("/* patch= */ ", version.patch()), "suffix", absl::StrCat("/* patch= */ ", version.patch()), "suffix",
absl::StrCat("/* suffix= */ \"", version.suffix(), "\""), "location", absl::StrCat("/* suffix= */ \"", version.suffix(), "\""), "location",
absl::StrCat(java_class_name, ".class.getName()")); absl::StrCat(java_class_name, ".class.getName()"));
} else {
printer->Print(
"com.google.protobuf.RuntimeVersion.validateProtobufGencodeDomain(\n"
" "
"com.google.protobuf.RuntimeVersion.RuntimeDomain.GOOGLE_INTERNAL);\n");
}
} }
std::string UnderscoresToCamelCase(absl::string_view input, std::string UnderscoresToCamelCase(absl::string_view input,

@ -16,9 +16,6 @@
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include "google/protobuf/compiler/plugin.pb.h" #include "google/protobuf/compiler/plugin.pb.h"
// Must be included last.
#include "google/protobuf/port_def.inc"
namespace google { namespace google {
namespace protobuf { namespace protobuf {
namespace compiler { namespace compiler {
@ -40,29 +37,22 @@ Version ParseProtobufVersion(absl::string_view version) {
} }
} // namespace internal } // namespace internal
const Version& GetProtobufCPPVersion(bool oss_runtime) { const Version& GetProtobufCPPVersion() {
absl::string_view version = PROTOBUF_CPP_VERSION_STRING;
// Heap-allocated versions to avoid re-parsing version strings // Heap-allocated versions to avoid re-parsing version strings
static const Version* cpp_version = static const Version* cpp_version =
new Version(internal::ParseProtobufVersion(version)); new Version(internal::ParseProtobufVersion(PROTOBUF_CPP_VERSION_STRING));
return *cpp_version; return *cpp_version;
} }
const Version& GetProtobufJavaVersion() {
const Version& GetProtobufJavaVersion(bool oss_runtime) {
absl::string_view version = PROTOBUF_JAVA_VERSION_STRING;
static const Version* java_version = static const Version* java_version =
new Version(internal::ParseProtobufVersion(version)); new Version(internal::ParseProtobufVersion(PROTOBUF_JAVA_VERSION_STRING));
return *java_version; return *java_version;
} }
const Version& GetProtobufPythonVersion() {
const Version& GetProtobufPythonVersion(bool oss_runtime) { static const Version* python_version = new Version(
absl::string_view version = PROTOBUF_PYTHON_VERSION_STRING; internal::ParseProtobufVersion(PROTOBUF_PYTHON_VERSION_STRING));
static const Version* python_version =
new Version(internal::ParseProtobufVersion(version));
return *python_version; return *python_version;
} }
} // namespace compiler } // namespace compiler
} // namespace protobuf } // namespace protobuf
} // namespace google } // namespace google
#include "google/protobuf/port_undef.inc"

@ -67,9 +67,9 @@ PROTOC_EXPORT Version ParseProtobufVersion(absl::string_view version);
} // namespace internal } // namespace internal
// Gets the version message according to the version strings defined above. // Gets the version message according to the version strings defined above.
const Version& GetProtobufCPPVersion(bool oss_runtime); const Version& GetProtobufCPPVersion();
const Version& GetProtobufJavaVersion(bool oss_runtime); const Version& GetProtobufJavaVersion();
const Version& GetProtobufPythonVersion(bool oss_runtime); const Version& GetProtobufPythonVersion();
} // namespace compiler } // namespace compiler
} // namespace protobuf } // namespace protobuf
} // namespace google } // namespace google

Loading…
Cancel
Save