Description
Version: v3.22.3
It looks like when some function declarations were moved from helpers.h
to names.h
the declaration of the function UnderscoresToCapitalizedCamelCase
was lost. It's source code is still present in names.cc
(it was moved there from helpers.cc
), but it ceased to be accessible to the library users (unless you add the declaration yourself, which is, obviously, a hack). We used it in our protobuf plugin which doesn't compile after the update. The breaking changes were not announced in the release notes, though. Internally, UnderscoresToCapitalizedCamelCase
isn't used in protobuf sources anymore, but the source was kept there, meaning that it is supposed to be used outside the library source code.
The boolean flag cap_next_letter
is available only for the function with string_view
input, but not for FieldDescriptor*
.
There are also some mistakes in the documentation comments:
cap_next_letter
parameter is referenced as "cap_first_letter" in the comment;
UnderscoresToCamelCase
without the boolean flag is said to return "fooBarBaz" or "FooBarBaz"
which is impossible for a function without a corresponding flag. This comment initially corresponded to two functions placed together (see declarations of UnderscoresToCamelCase
& UnderscoresToCapitalizedCamelCase
for version 3.21.1 below), but was copy-pasted as is, while the second function was lost.
Problematic version v3.22.3:
src/google/protobuf/compiler/java/names.h:
// Returns:
// Converts a name to camel-case. If cap_first_letter is true, capitalize the
// first letter.
std::string UnderscoresToCamelCase(absl::string_view input,
bool cap_next_letter);
// Requires:
// field != NULL
// Returns:
// Converts the field's name to camel-case, e.g. "foo_bar_baz" becomes
// "fooBarBaz" or "FooBarBaz", respectively.
std::string UnderscoresToCamelCase(const FieldDescriptor* field);
src/google/protobuf/compiler/java/names.cc:
std::string UnderscoresToCapitalizedCamelCase(const FieldDescriptor* field) {
return UnderscoresToCamelCase(FieldName(field), true);
}
How it was in 3.21.1:
src/google/protobuf/compiler/java/helpers.h:
// Converts a name to camel-case. If cap_first_letter is true, capitalize the
// first letter.
std::string UnderscoresToCamelCase(const std::string& name,
bool cap_first_letter);
// Converts the field's name to camel-case, e.g. "foo_bar_baz" becomes
// "fooBarBaz" or "FooBarBaz", respectively.
std::string UnderscoresToCamelCase(const FieldDescriptor* field);
std::string UnderscoresToCapitalizedCamelCase(const FieldDescriptor* field);
src/google/protobuf/compiler/java/helpers.cc:
std::string UnderscoresToCapitalizedCamelCase(const FieldDescriptor* field) {
return UnderscoresToCamelCase(FieldName(field), true);
}
Activity