|
|
|
@ -34,16 +34,11 @@ |
|
|
|
|
#include <map> |
|
|
|
|
#include <string> |
|
|
|
|
#include <google/protobuf/compiler/objectivec/objectivec_helpers.h> |
|
|
|
|
#include <google/protobuf/stubs/common.h> |
|
|
|
|
#include <google/protobuf/descriptor.h> |
|
|
|
|
#include <google/protobuf/io/printer.h> |
|
|
|
|
|
|
|
|
|
namespace google { |
|
|
|
|
namespace protobuf { |
|
|
|
|
|
|
|
|
|
namespace io { |
|
|
|
|
class Printer; // printer.h
|
|
|
|
|
} // namespace io
|
|
|
|
|
|
|
|
|
|
namespace compiler { |
|
|
|
|
namespace objectivec { |
|
|
|
|
|
|
|
|
@ -54,6 +49,9 @@ class FieldGenerator { |
|
|
|
|
|
|
|
|
|
virtual ~FieldGenerator(); |
|
|
|
|
|
|
|
|
|
FieldGenerator(const FieldGenerator&) = delete; |
|
|
|
|
FieldGenerator& operator=(const FieldGenerator&) = delete; |
|
|
|
|
|
|
|
|
|
// Exposed for subclasses to fill in.
|
|
|
|
|
virtual void GenerateFieldStorageDeclaration(io::Printer* printer) const = 0; |
|
|
|
|
virtual void GeneratePropertyDeclaration(io::Printer* printer) const = 0; |
|
|
|
@ -101,15 +99,15 @@ class FieldGenerator { |
|
|
|
|
|
|
|
|
|
const FieldDescriptor* descriptor_; |
|
|
|
|
std::map<string, string> variables_; |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGenerator); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
class SingleFieldGenerator : public FieldGenerator { |
|
|
|
|
public: |
|
|
|
|
virtual ~SingleFieldGenerator(); |
|
|
|
|
|
|
|
|
|
SingleFieldGenerator(const SingleFieldGenerator&) = delete; |
|
|
|
|
SingleFieldGenerator& operator=(const SingleFieldGenerator&) = delete; |
|
|
|
|
|
|
|
|
|
virtual void GenerateFieldStorageDeclaration(io::Printer* printer) const; |
|
|
|
|
virtual void GeneratePropertyDeclaration(io::Printer* printer) const; |
|
|
|
|
|
|
|
|
@ -121,9 +119,6 @@ class SingleFieldGenerator : public FieldGenerator { |
|
|
|
|
SingleFieldGenerator(const FieldDescriptor* descriptor, |
|
|
|
|
const Options& options); |
|
|
|
|
virtual bool WantsHasProperty(void) const; |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SingleFieldGenerator); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// Subclass with common support for when the field ends up as an ObjC Object.
|
|
|
|
@ -131,21 +126,24 @@ class ObjCObjFieldGenerator : public SingleFieldGenerator { |
|
|
|
|
public: |
|
|
|
|
virtual ~ObjCObjFieldGenerator(); |
|
|
|
|
|
|
|
|
|
ObjCObjFieldGenerator(const ObjCObjFieldGenerator&) = delete; |
|
|
|
|
ObjCObjFieldGenerator& operator=(const ObjCObjFieldGenerator&) = delete; |
|
|
|
|
|
|
|
|
|
virtual void GenerateFieldStorageDeclaration(io::Printer* printer) const; |
|
|
|
|
virtual void GeneratePropertyDeclaration(io::Printer* printer) const; |
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
|
ObjCObjFieldGenerator(const FieldDescriptor* descriptor, |
|
|
|
|
const Options& options); |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ObjCObjFieldGenerator); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
class RepeatedFieldGenerator : public ObjCObjFieldGenerator { |
|
|
|
|
public: |
|
|
|
|
virtual ~RepeatedFieldGenerator(); |
|
|
|
|
|
|
|
|
|
RepeatedFieldGenerator(const RepeatedFieldGenerator&) = delete; |
|
|
|
|
RepeatedFieldGenerator& operator=(const RepeatedFieldGenerator&) = delete; |
|
|
|
|
|
|
|
|
|
virtual void GenerateFieldStorageDeclaration(io::Printer* printer) const; |
|
|
|
|
virtual void GeneratePropertyDeclaration(io::Printer* printer) const; |
|
|
|
|
|
|
|
|
@ -158,9 +156,6 @@ class RepeatedFieldGenerator : public ObjCObjFieldGenerator { |
|
|
|
|
const Options& options); |
|
|
|
|
virtual void FinishInitialization(void); |
|
|
|
|
virtual bool WantsHasProperty(void) const; |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedFieldGenerator); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// Convenience class which constructs FieldGenerators for a Descriptor.
|
|
|
|
@ -169,6 +164,9 @@ class FieldGeneratorMap { |
|
|
|
|
FieldGeneratorMap(const Descriptor* descriptor, const Options& options); |
|
|
|
|
~FieldGeneratorMap(); |
|
|
|
|
|
|
|
|
|
FieldGeneratorMap(const FieldGeneratorMap&) = delete; |
|
|
|
|
FieldGeneratorMap& operator=(const FieldGeneratorMap&) = delete; |
|
|
|
|
|
|
|
|
|
const FieldGenerator& get(const FieldDescriptor* field) const; |
|
|
|
|
const FieldGenerator& get_extension(int index) const; |
|
|
|
|
|
|
|
|
@ -184,11 +182,11 @@ class FieldGeneratorMap { |
|
|
|
|
const Descriptor* descriptor_; |
|
|
|
|
std::vector<std::unique_ptr<FieldGenerator>> field_generators_; |
|
|
|
|
std::vector<std::unique_ptr<FieldGenerator>> extension_generators_; |
|
|
|
|
|
|
|
|
|
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorMap); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
} // namespace objectivec
|
|
|
|
|
} // namespace compiler
|
|
|
|
|
} // namespace protobuf
|
|
|
|
|
} // namespace google
|
|
|
|
|
|
|
|
|
|
#endif // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_FIELD_H__
|
|
|
|
|