[ObjC] Final const cleanups for generator.

PiperOrigin-RevId: 491355456
pull/11059/head
Protobuf Team Bot 2 years ago committed by Copybara-Service
parent e8a9dcb0df
commit 7a7bdde799
  1. 8
      src/google/protobuf/compiler/objectivec/file.cc
  2. 10
      src/google/protobuf/compiler/objectivec/file.h
  3. 15
      src/google/protobuf/compiler/objectivec/oneof.cc
  4. 10
      src/google/protobuf/compiler/objectivec/oneof.h

@ -221,7 +221,7 @@ FileGenerator::FileGenerator(const FileDescriptor* file,
CommonState& common_state)
: file_(file),
generation_options_(generation_options),
common_state_(common_state),
common_state_(&common_state),
root_class_name_(FileClassName(file)),
is_bundled_proto_(IsProtobufLibraryBundledProtoFile(file)) {
for (int i = 0; i < file_->enum_type_count(); i++) {
@ -241,7 +241,7 @@ FileGenerator::FileGenerator(const FileDescriptor* file,
}
}
void FileGenerator::GenerateHeader(io::Printer* printer) {
void FileGenerator::GenerateHeader(io::Printer* printer) const {
std::vector<std::string> headers;
// Generated files bundled with the library get minimal imports, everything
// else gets the wrapper so everything is usable.
@ -393,7 +393,7 @@ void FileGenerator::GenerateHeader(io::Printer* printer) {
// clang-format on
}
void FileGenerator::GenerateSource(io::Printer* printer) {
void FileGenerator::GenerateSource(io::Printer* printer) const {
// #import the runtime support.
std::vector<std::string> headers;
headers.push_back("GPBProtocolBuffers_RuntimeSupport.h");
@ -410,7 +410,7 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
}
std::vector<const FileDescriptor*> deps_with_extensions =
common_state_.CollectMinimalFileDepsContainingExtensions(file_);
common_state_->CollectMinimalFileDepsContainingExtensions(file_);
// The bundled protos (WKTs) don't use of forward declarations.
bool headers_use_forward_declarations =

@ -80,15 +80,15 @@ class FileGenerator {
FileGenerator(const FileGenerator&) = delete;
FileGenerator& operator=(const FileGenerator&) = delete;
void GenerateSource(io::Printer* printer);
void GenerateHeader(io::Printer* printer);
void GenerateSource(io::Printer* printer) const;
void GenerateHeader(io::Printer* printer) const;
private:
const FileDescriptor* file_;
const GenerationOptions& generation_options_;
CommonState& common_state_;
std::string root_class_name_;
bool is_bundled_proto_;
mutable CommonState* common_state_;
const std::string root_class_name_;
const bool is_bundled_proto_;
std::vector<std::unique_ptr<EnumGenerator>> enum_generators_;
std::vector<std::unique_ptr<MessageGenerator>> message_generators_;

@ -67,11 +67,11 @@ void OneofGenerator::SetOneofIndexBase(int index_base) {
variables_["index"] = absl::StrCat(-index);
}
void OneofGenerator::GenerateCaseEnum(io::Printer* printer) {
void OneofGenerator::GenerateCaseEnum(io::Printer* printer) const {
printer->Print(variables_, "typedef GPB_ENUM($enum_name$) {\n");
printer->Indent();
printer->Print(variables_, "$enum_name$_GPBUnsetOneOfCase = 0,\n");
std::string enum_name = variables_["enum_name"];
std::string enum_name = variables_.find("enum_name")->second;
for (int j = 0; j < descriptor_->field_count(); j++) {
const FieldDescriptor* field = descriptor_->field(j);
std::string field_name = FieldNameCapitalized(field);
@ -88,7 +88,7 @@ void OneofGenerator::GenerateCaseEnum(io::Printer* printer) {
}
void OneofGenerator::GeneratePublicCasePropertyDeclaration(
io::Printer* printer) {
io::Printer* printer) const {
// clang-format off
printer->Print(
variables_,
@ -98,7 +98,8 @@ void OneofGenerator::GeneratePublicCasePropertyDeclaration(
// clang-format on
}
void OneofGenerator::GenerateClearFunctionDeclaration(io::Printer* printer) {
void OneofGenerator::GenerateClearFunctionDeclaration(
io::Printer* printer) const {
// clang-format off
printer->Print(
variables_,
@ -109,11 +110,13 @@ void OneofGenerator::GenerateClearFunctionDeclaration(io::Printer* printer) {
// clang-format on
}
void OneofGenerator::GeneratePropertyImplementation(io::Printer* printer) {
void OneofGenerator::GeneratePropertyImplementation(
io::Printer* printer) const {
printer->Print(variables_, "@dynamic $name$OneOfCase;\n");
}
void OneofGenerator::GenerateClearFunctionImplementation(io::Printer* printer) {
void OneofGenerator::GenerateClearFunctionImplementation(
io::Printer* printer) const {
// clang-format off
printer->Print(
variables_,

@ -53,13 +53,13 @@ class OneofGenerator {
void SetOneofIndexBase(int index_base);
void GenerateCaseEnum(io::Printer* printer);
void GenerateCaseEnum(io::Printer* printer) const;
void GeneratePublicCasePropertyDeclaration(io::Printer* printer);
void GenerateClearFunctionDeclaration(io::Printer* printer);
void GeneratePublicCasePropertyDeclaration(io::Printer* printer) const;
void GenerateClearFunctionDeclaration(io::Printer* printer) const;
void GeneratePropertyImplementation(io::Printer* printer);
void GenerateClearFunctionImplementation(io::Printer* printer);
void GeneratePropertyImplementation(io::Printer* printer) const;
void GenerateClearFunctionImplementation(io::Printer* printer) const;
std::string DescriptorName() const;
std::string HasIndexAsString() const;

Loading…
Cancel
Save