[ObjC] Wire the generation options through all the Field generators.

Nothing uses this yet, just gets things wired through.

PiperOrigin-RevId: 568230626
pull/14170/head
Thomas Van Lenten 1 year ago committed by Copybara-Service
parent cde00514e9
commit d58ed887ff
  1. 12
      src/google/protobuf/compiler/objectivec/enum_field.cc
  2. 15
      src/google/protobuf/compiler/objectivec/enum_field.h
  3. 46
      src/google/protobuf/compiler/objectivec/field.cc
  4. 19
      src/google/protobuf/compiler/objectivec/field.h
  5. 10
      src/google/protobuf/compiler/objectivec/map_field.cc
  6. 8
      src/google/protobuf/compiler/objectivec/map_field.h
  7. 2
      src/google/protobuf/compiler/objectivec/message.cc
  8. 12
      src/google/protobuf/compiler/objectivec/message_field.cc
  9. 15
      src/google/protobuf/compiler/objectivec/message_field.h
  10. 16
      src/google/protobuf/compiler/objectivec/primitive_field.cc
  11. 22
      src/google/protobuf/compiler/objectivec/primitive_field.h

@ -16,6 +16,7 @@
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include "google/protobuf/compiler/objectivec/field.h" #include "google/protobuf/compiler/objectivec/field.h"
#include "google/protobuf/compiler/objectivec/names.h" #include "google/protobuf/compiler/objectivec/names.h"
#include "google/protobuf/compiler/objectivec/options.h"
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
#include "google/protobuf/io/printer.h" #include "google/protobuf/io/printer.h"
@ -50,8 +51,10 @@ void SetEnumVariables(
} }
} // namespace } // namespace
EnumFieldGenerator::EnumFieldGenerator(const FieldDescriptor* descriptor) EnumFieldGenerator::EnumFieldGenerator(
: SingleFieldGenerator(descriptor) { const FieldDescriptor* descriptor,
const GenerationOptions& generation_options)
: SingleFieldGenerator(descriptor, generation_options) {
SetEnumVariables(descriptor, &variables_); SetEnumVariables(descriptor, &variables_);
} }
@ -125,8 +128,9 @@ void EnumFieldGenerator::DetermineNeededFiles(
} }
RepeatedEnumFieldGenerator::RepeatedEnumFieldGenerator( RepeatedEnumFieldGenerator::RepeatedEnumFieldGenerator(
const FieldDescriptor* descriptor) const FieldDescriptor* descriptor,
: RepeatedFieldGenerator(descriptor) { const GenerationOptions& generation_options)
: RepeatedFieldGenerator(descriptor, generation_options) {
SetEnumVariables(descriptor, &variables_); SetEnumVariables(descriptor, &variables_);
} }

@ -13,6 +13,7 @@
#include "absl/container/btree_set.h" #include "absl/container/btree_set.h"
#include "absl/container/flat_hash_set.h" #include "absl/container/flat_hash_set.h"
#include "google/protobuf/compiler/objectivec/field.h" #include "google/protobuf/compiler/objectivec/field.h"
#include "google/protobuf/compiler/objectivec/options.h"
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
namespace google { namespace google {
@ -21,7 +22,9 @@ namespace compiler {
namespace objectivec { namespace objectivec {
class EnumFieldGenerator : public SingleFieldGenerator { class EnumFieldGenerator : public SingleFieldGenerator {
friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field); friend FieldGenerator* FieldGenerator::Make(
const FieldDescriptor* field,
const GenerationOptions& generation_options);
EnumFieldGenerator(const EnumFieldGenerator&) = delete; EnumFieldGenerator(const EnumFieldGenerator&) = delete;
EnumFieldGenerator& operator=(const EnumFieldGenerator&) = delete; EnumFieldGenerator& operator=(const EnumFieldGenerator&) = delete;
@ -35,12 +38,15 @@ class EnumFieldGenerator : public SingleFieldGenerator {
absl::flat_hash_set<const FileDescriptor*>* deps) const override; absl::flat_hash_set<const FileDescriptor*>* deps) const override;
protected: protected:
explicit EnumFieldGenerator(const FieldDescriptor* descriptor); EnumFieldGenerator(const FieldDescriptor* descriptor,
const GenerationOptions& generation_options);
~EnumFieldGenerator() override = default; ~EnumFieldGenerator() override = default;
}; };
class RepeatedEnumFieldGenerator : public RepeatedFieldGenerator { class RepeatedEnumFieldGenerator : public RepeatedFieldGenerator {
friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field); friend FieldGenerator* FieldGenerator::Make(
const FieldDescriptor* field,
const GenerationOptions& generation_options);
public: public:
void EmitArrayComment(io::Printer* printer) const override; void EmitArrayComment(io::Printer* printer) const override;
@ -48,7 +54,8 @@ class RepeatedEnumFieldGenerator : public RepeatedFieldGenerator {
absl::flat_hash_set<const FileDescriptor*>* deps) const override; absl::flat_hash_set<const FileDescriptor*>* deps) const override;
protected: protected:
explicit RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor); RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor,
const GenerationOptions& generation_options);
~RepeatedEnumFieldGenerator() override = default; ~RepeatedEnumFieldGenerator() override = default;
}; };

@ -23,6 +23,7 @@
#include "google/protobuf/compiler/objectivec/map_field.h" #include "google/protobuf/compiler/objectivec/map_field.h"
#include "google/protobuf/compiler/objectivec/message_field.h" #include "google/protobuf/compiler/objectivec/message_field.h"
#include "google/protobuf/compiler/objectivec/names.h" #include "google/protobuf/compiler/objectivec/names.h"
#include "google/protobuf/compiler/objectivec/options.h"
#include "google/protobuf/compiler/objectivec/primitive_field.h" #include "google/protobuf/compiler/objectivec/primitive_field.h"
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
#include "google/protobuf/io/printer.h" #include "google/protobuf/io/printer.h"
@ -156,39 +157,41 @@ bool HasNonZeroDefaultValue(const FieldDescriptor* field) {
} // namespace } // namespace
FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field) { FieldGenerator* FieldGenerator::Make(
const FieldDescriptor* field, const GenerationOptions& generation_options) {
if (field->is_repeated()) { if (field->is_repeated()) {
switch (GetObjectiveCType(field)) { switch (GetObjectiveCType(field)) {
case OBJECTIVECTYPE_MESSAGE: { case OBJECTIVECTYPE_MESSAGE: {
if (field->is_map()) { if (field->is_map()) {
return new MapFieldGenerator(field); return new MapFieldGenerator(field, generation_options);
} else { } else {
return new RepeatedMessageFieldGenerator(field); return new RepeatedMessageFieldGenerator(field, generation_options);
} }
} }
case OBJECTIVECTYPE_ENUM: case OBJECTIVECTYPE_ENUM:
return new RepeatedEnumFieldGenerator(field); return new RepeatedEnumFieldGenerator(field, generation_options);
default: default:
return new RepeatedPrimitiveFieldGenerator(field); return new RepeatedPrimitiveFieldGenerator(field, generation_options);
} }
} }
switch (GetObjectiveCType(field)) { switch (GetObjectiveCType(field)) {
case OBJECTIVECTYPE_MESSAGE: { case OBJECTIVECTYPE_MESSAGE: {
return new MessageFieldGenerator(field); return new MessageFieldGenerator(field, generation_options);
} }
case OBJECTIVECTYPE_ENUM: case OBJECTIVECTYPE_ENUM:
return new EnumFieldGenerator(field); return new EnumFieldGenerator(field, generation_options);
default: default:
if (IsReferenceType(field)) { if (IsReferenceType(field)) {
return new PrimitiveObjFieldGenerator(field); return new PrimitiveObjFieldGenerator(field, generation_options);
} else { } else {
return new PrimitiveFieldGenerator(field); return new PrimitiveFieldGenerator(field, generation_options);
} }
} }
} }
FieldGenerator::FieldGenerator(const FieldDescriptor* descriptor) FieldGenerator::FieldGenerator(const FieldDescriptor* descriptor,
const GenerationOptions& generation_options)
: descriptor_(descriptor) { : descriptor_(descriptor) {
SetCommonFieldVariables(descriptor, &variables_); SetCommonFieldVariables(descriptor, &variables_);
} }
@ -275,8 +278,10 @@ bool FieldGenerator::WantsHasProperty() const {
return descriptor_->has_presence() && !descriptor_->real_containing_oneof(); return descriptor_->has_presence() && !descriptor_->real_containing_oneof();
} }
SingleFieldGenerator::SingleFieldGenerator(const FieldDescriptor* descriptor) SingleFieldGenerator::SingleFieldGenerator(
: FieldGenerator(descriptor) { const FieldDescriptor* descriptor,
const GenerationOptions& generation_options)
: FieldGenerator(descriptor, generation_options) {
// Nothing // Nothing
} }
@ -321,8 +326,10 @@ bool SingleFieldGenerator::RuntimeUsesHasBit() const {
return true; return true;
} }
ObjCObjFieldGenerator::ObjCObjFieldGenerator(const FieldDescriptor* descriptor) ObjCObjFieldGenerator::ObjCObjFieldGenerator(
: SingleFieldGenerator(descriptor) { const FieldDescriptor* descriptor,
const GenerationOptions& generation_options)
: SingleFieldGenerator(descriptor, generation_options) {
variables_["property_storage_attribute"] = "strong"; variables_["property_storage_attribute"] = "strong";
if (IsRetainedName(variables_["name"])) { if (IsRetainedName(variables_["name"])) {
variables_["storage_attribute"] = " NS_RETURNS_NOT_RETAINED"; variables_["storage_attribute"] = " NS_RETURNS_NOT_RETAINED";
@ -365,8 +372,9 @@ void ObjCObjFieldGenerator::GeneratePropertyDeclaration(
} }
RepeatedFieldGenerator::RepeatedFieldGenerator( RepeatedFieldGenerator::RepeatedFieldGenerator(
const FieldDescriptor* descriptor) const FieldDescriptor* descriptor,
: ObjCObjFieldGenerator(descriptor) {} const GenerationOptions& generation_options)
: ObjCObjFieldGenerator(descriptor, generation_options) {}
void RepeatedFieldGenerator::GenerateFieldStorageDeclaration( void RepeatedFieldGenerator::GenerateFieldStorageDeclaration(
io::Printer* printer) const { io::Printer* printer) const {
@ -417,11 +425,13 @@ void RepeatedFieldGenerator::EmitArrayComment(io::Printer* printer) const {
// Nothing for the default // Nothing for the default
} }
FieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor) FieldGeneratorMap::FieldGeneratorMap(
const Descriptor* descriptor, const GenerationOptions& generation_options)
: descriptor_(descriptor), : descriptor_(descriptor),
field_generators_(static_cast<size_t>(descriptor->field_count())) { field_generators_(static_cast<size_t>(descriptor->field_count())) {
for (int i = 0; i < descriptor->field_count(); i++) { for (int i = 0; i < descriptor->field_count(); i++) {
field_generators_[i].reset(FieldGenerator::Make(descriptor->field(i))); field_generators_[i].reset(
FieldGenerator::Make(descriptor->field(i), generation_options));
} }
} }

@ -17,6 +17,7 @@
#include "absl/container/flat_hash_set.h" #include "absl/container/flat_hash_set.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include "google/protobuf/compiler/objectivec/options.h"
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
#include "google/protobuf/io/printer.h" #include "google/protobuf/io/printer.h"
@ -27,7 +28,8 @@ namespace objectivec {
class FieldGenerator { class FieldGenerator {
public: public:
static FieldGenerator* Make(const FieldDescriptor* field); static FieldGenerator* Make(const FieldDescriptor* field,
const GenerationOptions& generation_options);
virtual ~FieldGenerator() = default; virtual ~FieldGenerator() = default;
@ -80,7 +82,8 @@ class FieldGenerator {
std::string raw_field_name() const { return variable("raw_field_name"); } std::string raw_field_name() const { return variable("raw_field_name"); }
protected: protected:
explicit FieldGenerator(const FieldDescriptor* descriptor); FieldGenerator(const FieldDescriptor* descriptor,
const GenerationOptions& generation_options);
bool WantsHasProperty() const; bool WantsHasProperty() const;
@ -103,7 +106,8 @@ class SingleFieldGenerator : public FieldGenerator {
bool RuntimeUsesHasBit() const override; bool RuntimeUsesHasBit() const override;
protected: protected:
explicit SingleFieldGenerator(const FieldDescriptor* descriptor); SingleFieldGenerator(const FieldDescriptor* descriptor,
const GenerationOptions& generation_options);
}; };
// Subclass with common support for when the field ends up as an ObjC Object. // Subclass with common support for when the field ends up as an ObjC Object.
@ -118,7 +122,8 @@ class ObjCObjFieldGenerator : public SingleFieldGenerator {
void GeneratePropertyDeclaration(io::Printer* printer) const override; void GeneratePropertyDeclaration(io::Printer* printer) const override;
protected: protected:
explicit ObjCObjFieldGenerator(const FieldDescriptor* descriptor); ObjCObjFieldGenerator(const FieldDescriptor* descriptor,
const GenerationOptions& generation_options);
}; };
class RepeatedFieldGenerator : public ObjCObjFieldGenerator { class RepeatedFieldGenerator : public ObjCObjFieldGenerator {
@ -138,13 +143,15 @@ class RepeatedFieldGenerator : public ObjCObjFieldGenerator {
virtual void EmitArrayComment(io::Printer* printer) const; virtual void EmitArrayComment(io::Printer* printer) const;
protected: protected:
explicit RepeatedFieldGenerator(const FieldDescriptor* descriptor); RepeatedFieldGenerator(const FieldDescriptor* descriptor,
const GenerationOptions& generation_options);
}; };
// Convenience class which constructs FieldGenerators for a Descriptor. // Convenience class which constructs FieldGenerators for a Descriptor.
class FieldGeneratorMap { class FieldGeneratorMap {
public: public:
explicit FieldGeneratorMap(const Descriptor* descriptor); FieldGeneratorMap(const Descriptor* descriptor,
const GenerationOptions& generation_options);
~FieldGeneratorMap() = default; ~FieldGeneratorMap() = default;
FieldGeneratorMap(const FieldGeneratorMap&) = delete; FieldGeneratorMap(const FieldGeneratorMap&) = delete;

@ -17,6 +17,7 @@
#include "google/protobuf/compiler/objectivec/field.h" #include "google/protobuf/compiler/objectivec/field.h"
#include "google/protobuf/compiler/objectivec/helpers.h" #include "google/protobuf/compiler/objectivec/helpers.h"
#include "google/protobuf/compiler/objectivec/names.h" #include "google/protobuf/compiler/objectivec/names.h"
#include "google/protobuf/compiler/objectivec/options.h"
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
namespace google { namespace google {
@ -28,12 +29,15 @@ namespace objectivec {
// provides a bunch of things (no has* methods, comments for contained type, // provides a bunch of things (no has* methods, comments for contained type,
// etc.). // etc.).
MapFieldGenerator::MapFieldGenerator(const FieldDescriptor* descriptor) MapFieldGenerator::MapFieldGenerator(
: RepeatedFieldGenerator(descriptor) { const FieldDescriptor* descriptor,
const GenerationOptions& generation_options)
: RepeatedFieldGenerator(descriptor, generation_options) {
const FieldDescriptor* key_descriptor = descriptor->message_type()->map_key(); const FieldDescriptor* key_descriptor = descriptor->message_type()->map_key();
const FieldDescriptor* value_descriptor = const FieldDescriptor* value_descriptor =
descriptor->message_type()->map_value(); descriptor->message_type()->map_value();
value_field_generator_.reset(FieldGenerator::Make(value_descriptor)); value_field_generator_.reset(
FieldGenerator::Make(value_descriptor, generation_options));
// Pull over some variables_ from the value. // Pull over some variables_ from the value.
variables_["field_type"] = value_field_generator_->variable("field_type"); variables_["field_type"] = value_field_generator_->variable("field_type");

@ -14,6 +14,7 @@
#include "absl/container/btree_set.h" #include "absl/container/btree_set.h"
#include "absl/container/flat_hash_set.h" #include "absl/container/flat_hash_set.h"
#include "google/protobuf/compiler/objectivec/field.h" #include "google/protobuf/compiler/objectivec/field.h"
#include "google/protobuf/compiler/objectivec/options.h"
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
namespace google { namespace google {
@ -22,7 +23,9 @@ namespace compiler {
namespace objectivec { namespace objectivec {
class MapFieldGenerator : public RepeatedFieldGenerator { class MapFieldGenerator : public RepeatedFieldGenerator {
friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field); friend FieldGenerator* FieldGenerator::Make(
const FieldDescriptor* field,
const GenerationOptions& generation_options);
public: public:
void EmitArrayComment(io::Printer* printer) const override; void EmitArrayComment(io::Printer* printer) const override;
@ -31,7 +34,8 @@ class MapFieldGenerator : public RepeatedFieldGenerator {
MapFieldGenerator& operator=(const MapFieldGenerator&) = delete; MapFieldGenerator& operator=(const MapFieldGenerator&) = delete;
protected: protected:
explicit MapFieldGenerator(const FieldDescriptor* descriptor); MapFieldGenerator(const FieldDescriptor* descriptor,
const GenerationOptions& generation_options);
~MapFieldGenerator() override = default; ~MapFieldGenerator() override = default;
void DetermineObjectiveCClassDefinitions( void DetermineObjectiveCClassDefinitions(

@ -198,7 +198,7 @@ MessageGenerator::MessageGenerator(const std::string& file_description_name,
: file_description_name_(file_description_name), : file_description_name_(file_description_name),
descriptor_(descriptor), descriptor_(descriptor),
generation_options_(generation_options), generation_options_(generation_options),
field_generators_(descriptor), field_generators_(descriptor, generation_options),
class_name_(ClassName(descriptor_)), class_name_(ClassName(descriptor_)),
deprecated_attribute_( deprecated_attribute_(
GetOptionalDeprecatedAttribute(descriptor, descriptor->file())) { GetOptionalDeprecatedAttribute(descriptor, descriptor->file())) {

@ -17,6 +17,7 @@
#include "google/protobuf/compiler/objectivec/field.h" #include "google/protobuf/compiler/objectivec/field.h"
#include "google/protobuf/compiler/objectivec/helpers.h" #include "google/protobuf/compiler/objectivec/helpers.h"
#include "google/protobuf/compiler/objectivec/names.h" #include "google/protobuf/compiler/objectivec/names.h"
#include "google/protobuf/compiler/objectivec/options.h"
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
namespace google { namespace google {
@ -39,8 +40,10 @@ void SetMessageVariables(
} // namespace } // namespace
MessageFieldGenerator::MessageFieldGenerator(const FieldDescriptor* descriptor) MessageFieldGenerator::MessageFieldGenerator(
: ObjCObjFieldGenerator(descriptor) { const FieldDescriptor* descriptor,
const GenerationOptions& generation_options)
: ObjCObjFieldGenerator(descriptor, generation_options) {
SetMessageVariables(descriptor, &variables_); SetMessageVariables(descriptor, &variables_);
} }
@ -72,8 +75,9 @@ void MessageFieldGenerator::DetermineNeededFiles(
} }
RepeatedMessageFieldGenerator::RepeatedMessageFieldGenerator( RepeatedMessageFieldGenerator::RepeatedMessageFieldGenerator(
const FieldDescriptor* descriptor) const FieldDescriptor* descriptor,
: RepeatedFieldGenerator(descriptor) { const GenerationOptions& generation_options)
: RepeatedFieldGenerator(descriptor, generation_options) {
SetMessageVariables(descriptor, &variables_); SetMessageVariables(descriptor, &variables_);
} }

@ -13,6 +13,7 @@
#include "absl/container/btree_set.h" #include "absl/container/btree_set.h"
#include "absl/container/flat_hash_set.h" #include "absl/container/flat_hash_set.h"
#include "google/protobuf/compiler/objectivec/field.h" #include "google/protobuf/compiler/objectivec/field.h"
#include "google/protobuf/compiler/objectivec/options.h"
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
namespace google { namespace google {
@ -21,10 +22,13 @@ namespace compiler {
namespace objectivec { namespace objectivec {
class MessageFieldGenerator : public ObjCObjFieldGenerator { class MessageFieldGenerator : public ObjCObjFieldGenerator {
friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field); friend FieldGenerator* FieldGenerator::Make(
const FieldDescriptor* field,
const GenerationOptions& generation_options);
protected: protected:
explicit MessageFieldGenerator(const FieldDescriptor* descriptor); MessageFieldGenerator(const FieldDescriptor* descriptor,
const GenerationOptions& generation_options);
~MessageFieldGenerator() override = default; ~MessageFieldGenerator() override = default;
MessageFieldGenerator(const MessageFieldGenerator&) = delete; MessageFieldGenerator(const MessageFieldGenerator&) = delete;
@ -40,10 +44,13 @@ class MessageFieldGenerator : public ObjCObjFieldGenerator {
}; };
class RepeatedMessageFieldGenerator : public RepeatedFieldGenerator { class RepeatedMessageFieldGenerator : public RepeatedFieldGenerator {
friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field); friend FieldGenerator* FieldGenerator::Make(
const FieldDescriptor* field,
const GenerationOptions& generation_options);
protected: protected:
explicit RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor); RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor,
const GenerationOptions& generation_options);
~RepeatedMessageFieldGenerator() override = default; ~RepeatedMessageFieldGenerator() override = default;
RepeatedMessageFieldGenerator(const RepeatedMessageFieldGenerator&) = delete; RepeatedMessageFieldGenerator(const RepeatedMessageFieldGenerator&) = delete;

@ -13,6 +13,7 @@
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "google/protobuf/compiler/objectivec/field.h" #include "google/protobuf/compiler/objectivec/field.h"
#include "google/protobuf/compiler/objectivec/helpers.h" #include "google/protobuf/compiler/objectivec/helpers.h"
#include "google/protobuf/compiler/objectivec/options.h"
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
#include "google/protobuf/io/printer.h" #include "google/protobuf/io/printer.h"
@ -22,8 +23,9 @@ namespace compiler {
namespace objectivec { namespace objectivec {
PrimitiveFieldGenerator::PrimitiveFieldGenerator( PrimitiveFieldGenerator::PrimitiveFieldGenerator(
const FieldDescriptor* descriptor) const FieldDescriptor* descriptor,
: SingleFieldGenerator(descriptor) {} const GenerationOptions& generation_options)
: SingleFieldGenerator(descriptor, generation_options) {}
void PrimitiveFieldGenerator::GenerateFieldStorageDeclaration( void PrimitiveFieldGenerator::GenerateFieldStorageDeclaration(
io::Printer* printer) const { io::Printer* printer) const {
@ -52,14 +54,16 @@ void PrimitiveFieldGenerator::SetExtraRuntimeHasBitsBase(int index_base) {
} }
PrimitiveObjFieldGenerator::PrimitiveObjFieldGenerator( PrimitiveObjFieldGenerator::PrimitiveObjFieldGenerator(
const FieldDescriptor* descriptor) const FieldDescriptor* descriptor,
: ObjCObjFieldGenerator(descriptor) { const GenerationOptions& generation_options)
: ObjCObjFieldGenerator(descriptor, generation_options) {
variables_["property_storage_attribute"] = "copy"; variables_["property_storage_attribute"] = "copy";
} }
RepeatedPrimitiveFieldGenerator::RepeatedPrimitiveFieldGenerator( RepeatedPrimitiveFieldGenerator::RepeatedPrimitiveFieldGenerator(
const FieldDescriptor* descriptor) const FieldDescriptor* descriptor,
: RepeatedFieldGenerator(descriptor) {} const GenerationOptions& generation_options)
: RepeatedFieldGenerator(descriptor, generation_options) {}
} // namespace objectivec } // namespace objectivec
} // namespace compiler } // namespace compiler

@ -9,6 +9,7 @@
#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_PRIMITIVE_FIELD_H__ #define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_PRIMITIVE_FIELD_H__
#include "google/protobuf/compiler/objectivec/field.h" #include "google/protobuf/compiler/objectivec/field.h"
#include "google/protobuf/compiler/objectivec/options.h"
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
namespace google { namespace google {
@ -17,10 +18,13 @@ namespace compiler {
namespace objectivec { namespace objectivec {
class PrimitiveFieldGenerator : public SingleFieldGenerator { class PrimitiveFieldGenerator : public SingleFieldGenerator {
friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field); friend FieldGenerator* FieldGenerator::Make(
const FieldDescriptor* field,
const GenerationOptions& generation_options);
protected: protected:
explicit PrimitiveFieldGenerator(const FieldDescriptor* descriptor); PrimitiveFieldGenerator(const FieldDescriptor* descriptor,
const GenerationOptions& generation_options);
~PrimitiveFieldGenerator() override = default; ~PrimitiveFieldGenerator() override = default;
PrimitiveFieldGenerator(const PrimitiveFieldGenerator&) = delete; PrimitiveFieldGenerator(const PrimitiveFieldGenerator&) = delete;
@ -33,10 +37,13 @@ class PrimitiveFieldGenerator : public SingleFieldGenerator {
}; };
class PrimitiveObjFieldGenerator : public ObjCObjFieldGenerator { class PrimitiveObjFieldGenerator : public ObjCObjFieldGenerator {
friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field); friend FieldGenerator* FieldGenerator::Make(
const FieldDescriptor* field,
const GenerationOptions& generation_options);
protected: protected:
explicit PrimitiveObjFieldGenerator(const FieldDescriptor* descriptor); PrimitiveObjFieldGenerator(const FieldDescriptor* descriptor,
const GenerationOptions& generation_options);
~PrimitiveObjFieldGenerator() override = default; ~PrimitiveObjFieldGenerator() override = default;
PrimitiveObjFieldGenerator(const PrimitiveObjFieldGenerator&) = delete; PrimitiveObjFieldGenerator(const PrimitiveObjFieldGenerator&) = delete;
@ -45,10 +52,13 @@ class PrimitiveObjFieldGenerator : public ObjCObjFieldGenerator {
}; };
class RepeatedPrimitiveFieldGenerator : public RepeatedFieldGenerator { class RepeatedPrimitiveFieldGenerator : public RepeatedFieldGenerator {
friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field); friend FieldGenerator* FieldGenerator::Make(
const FieldDescriptor* field,
const GenerationOptions& generation_options);
protected: protected:
explicit RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor); RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor,
const GenerationOptions& generation_options);
~RepeatedPrimitiveFieldGenerator() override = default; ~RepeatedPrimitiveFieldGenerator() override = default;
RepeatedPrimitiveFieldGenerator(const RepeatedPrimitiveFieldGenerator&) = RepeatedPrimitiveFieldGenerator(const RepeatedPrimitiveFieldGenerator&) =

Loading…
Cancel
Save