diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/src/google/protobuf/compiler/cpp/cpp_helpers.cc index b502618eac..4e19fdcd01 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.cc +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.cc @@ -69,10 +69,6 @@ static const char kAnyMessageName[] = "Any"; static const char kAnyProtoFile[] = "google/protobuf/any.proto"; static const char kGoogleProtobufPrefix[] = "google/protobuf/"; -std::string DotsToUnderscores(const std::string& name) { - return StringReplace(name, ".", "_", true); -} - std::string DotsToColons(const std::string& name) { return StringReplace(name, ".", "::", true); } diff --git a/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc b/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc index a21dc0a495..fcc0aec0ac 100644 --- a/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc +++ b/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc @@ -56,7 +56,8 @@ void WriteDocCommentBodyImpl(io::Printer* printer, SourceLocation location) { // node of a summary element, not part of an attribute. comments = StringReplace(comments, "&", "&", true); comments = StringReplace(comments, "<", "<", true); - std::vector lines = Split(comments, "\n", false /* skip_empty */); + std::vector lines; + SplitStringAllowEmpty(comments, "\n", &lines); // TODO: We really should work out which part to put in the summary and which to put in the remarks... // but that needs to be part of a bigger effort to understand the markdown better anyway. printer->Print("/// \n"); diff --git a/src/google/protobuf/compiler/csharp/csharp_enum.cc b/src/google/protobuf/compiler/csharp/csharp_enum.cc index 32c719907c..f457096633 100644 --- a/src/google/protobuf/compiler/csharp/csharp_enum.cc +++ b/src/google/protobuf/compiler/csharp/csharp_enum.cc @@ -31,7 +31,6 @@ #include #include -#include #include #include #include diff --git a/src/google/protobuf/compiler/csharp/csharp_enum.h b/src/google/protobuf/compiler/csharp/csharp_enum.h index 5170d839b9..e409c2e4b2 100644 --- a/src/google/protobuf/compiler/csharp/csharp_enum.h +++ b/src/google/protobuf/compiler/csharp/csharp_enum.h @@ -48,12 +48,13 @@ class EnumGenerator : public SourceGeneratorBase { EnumGenerator(const EnumDescriptor* descriptor, const Options* options); ~EnumGenerator(); + EnumGenerator(const EnumGenerator&) = delete; + EnumGenerator& operator=(const EnumGenerator&) = delete; + void Generate(io::Printer* printer); private: const EnumDescriptor* descriptor_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator); }; } // namespace csharp diff --git a/src/google/protobuf/compiler/csharp/csharp_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_enum_field.cc index df5996148c..4d9bb67224 100644 --- a/src/google/protobuf/compiler/csharp/csharp_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_enum_field.cc @@ -31,7 +31,6 @@ #include #include -#include #include #include #include diff --git a/src/google/protobuf/compiler/csharp/csharp_enum_field.h b/src/google/protobuf/compiler/csharp/csharp_enum_field.h index bfb9bc81dd..04ca68da6e 100644 --- a/src/google/protobuf/compiler/csharp/csharp_enum_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_enum_field.h @@ -48,13 +48,13 @@ class EnumFieldGenerator : public PrimitiveFieldGenerator { const Options *options); ~EnumFieldGenerator(); + EnumFieldGenerator(const EnumFieldGenerator&) = delete; + EnumFieldGenerator& operator=(const EnumFieldGenerator&) = delete; + virtual void GenerateCodecCode(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); virtual void GenerateSerializationCode(io::Printer* printer); virtual void GenerateSerializedSizeCode(io::Printer* printer); - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator); }; class EnumOneofFieldGenerator : public PrimitiveOneofFieldGenerator { @@ -64,13 +64,13 @@ class EnumOneofFieldGenerator : public PrimitiveOneofFieldGenerator { const Options *options); ~EnumOneofFieldGenerator(); + EnumOneofFieldGenerator(const EnumOneofFieldGenerator&) = delete; + EnumOneofFieldGenerator& operator=(const EnumOneofFieldGenerator&) = delete; + virtual void GenerateMergingCode(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); virtual void GenerateSerializationCode(io::Printer* printer); virtual void GenerateSerializedSizeCode(io::Printer* printer); - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumOneofFieldGenerator); }; } // namespace csharp diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc index 90b01b647e..02adfeae13 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -28,17 +28,16 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include #include #include #include -#include #include #include #include #include #include -#include #include #include @@ -323,7 +322,7 @@ std::string FieldGeneratorBase::default_value(const FieldDescriptor* descriptor) return "double.PositiveInfinity"; } else if (value == -std::numeric_limits::infinity()) { return "double.NegativeInfinity"; - } else if (MathLimits::IsNaN(value)) { + } else if (std::isnan(value)) { return "double.NaN"; } return SimpleDtoa(value) + "D"; @@ -334,7 +333,7 @@ std::string FieldGeneratorBase::default_value(const FieldDescriptor* descriptor) return "float.PositiveInfinity"; } else if (value == -std::numeric_limits::infinity()) { return "float.NegativeInfinity"; - } else if (MathLimits::IsNaN(value)) { + } else if (std::isnan(value)) { return "float.NaN"; } return SimpleFtoa(value) + "F"; diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.h b/src/google/protobuf/compiler/csharp/csharp_field_base.h index 7eee6bf1bc..28a096217a 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.h +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.h @@ -51,6 +51,9 @@ class FieldGeneratorBase : public SourceGeneratorBase { const Options* options); ~FieldGeneratorBase(); + FieldGeneratorBase(const FieldGeneratorBase&) = delete; + FieldGeneratorBase& operator=(const FieldGeneratorBase&) = delete; + virtual void GenerateCloningCode(io::Printer* printer) = 0; virtual void GenerateFreezingCode(io::Printer* printer); virtual void GenerateCodecCode(io::Printer* printer); @@ -93,8 +96,6 @@ class FieldGeneratorBase : public SourceGeneratorBase { void SetCommonFieldVariables(std::map* variables); std::string GetStringDefaultValueInternal(const FieldDescriptor* descriptor); std::string GetBytesDefaultValueInternal(const FieldDescriptor* descriptor); - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorBase); }; } // namespace csharp diff --git a/src/google/protobuf/compiler/csharp/csharp_generator.cc b/src/google/protobuf/compiler/csharp/csharp_generator.cc index 5b01629197..2b353b3413 100644 --- a/src/google/protobuf/compiler/csharp/csharp_generator.cc +++ b/src/google/protobuf/compiler/csharp/csharp_generator.cc @@ -31,7 +31,6 @@ #include #include -#include #include #include #include @@ -49,8 +48,7 @@ namespace protobuf { namespace compiler { namespace csharp { -void GenerateFile(const google::protobuf::FileDescriptor* file, - io::Printer* printer, +void GenerateFile(const FileDescriptor* file, io::Printer* printer, const Options* options) { ReflectionClassGenerator reflectionClassGenerator(file, options); reflectionClassGenerator.Generate(printer); diff --git a/src/google/protobuf/compiler/csharp/csharp_generator.h b/src/google/protobuf/compiler/csharp/csharp_generator.h index 1ed36ab5c5..da72e0e776 100644 --- a/src/google/protobuf/compiler/csharp/csharp_generator.h +++ b/src/google/protobuf/compiler/csharp/csharp_generator.h @@ -48,8 +48,7 @@ namespace csharp { // header. If you create your own protocol compiler binary and you want // it to support C# output, you can do so by registering an instance of this // CodeGenerator with the CommandLineInterface in your main() function. -class PROTOC_EXPORT Generator - : public PROTOBUF_NAMESPACE_ID::compiler::CodeGenerator { +class PROTOC_EXPORT Generator : public CodeGenerator { public: virtual bool Generate( const FileDescriptor* file, diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc index 74dd0c985e..e8b5dcda41 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc @@ -33,7 +33,6 @@ // Sanjay Ghemawat, Jeff Dean, and others. #include -#include #include #include #include @@ -44,7 +43,6 @@ #include #include #include -#include #include #include @@ -355,12 +353,10 @@ std::string GetPropertyName(const FieldDescriptor* descriptor) { return property_name; } -std::string GetOutputFile( - const google::protobuf::FileDescriptor* descriptor, - const std::string file_extension, - const bool generate_directories, - const std::string base_namespace, - string* error) { +std::string GetOutputFile(const FileDescriptor* descriptor, + const std::string file_extension, + const bool generate_directories, + const std::string base_namespace, string* error) { string relative_filename = GetFileNameBase(descriptor) + file_extension; if (!generate_directories) { return relative_filename; diff --git a/src/google/protobuf/compiler/csharp/csharp_map_field.cc b/src/google/protobuf/compiler/csharp/csharp_map_field.cc index 3519f18aa6..f3f09ea454 100644 --- a/src/google/protobuf/compiler/csharp/csharp_map_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_map_field.cc @@ -31,7 +31,6 @@ #include #include -#include #include #include #include diff --git a/src/google/protobuf/compiler/csharp/csharp_map_field.h b/src/google/protobuf/compiler/csharp/csharp_map_field.h index 91c99bd052..b920b9f225 100644 --- a/src/google/protobuf/compiler/csharp/csharp_map_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_map_field.h @@ -48,6 +48,9 @@ class MapFieldGenerator : public FieldGeneratorBase { const Options* options); ~MapFieldGenerator(); + MapFieldGenerator(const MapFieldGenerator&) = delete; + MapFieldGenerator& operator=(const MapFieldGenerator&) = delete; + virtual void GenerateCloningCode(io::Printer* printer); virtual void GenerateFreezingCode(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer); @@ -59,9 +62,6 @@ class MapFieldGenerator : public FieldGeneratorBase { virtual void WriteHash(io::Printer* printer); virtual void WriteEquals(io::Printer* printer); virtual void WriteToString(io::Printer* printer); - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapFieldGenerator); }; } // namespace csharp diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 7157580db9..e365463bf2 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -33,7 +33,6 @@ #include #include -#include #include #include #include diff --git a/src/google/protobuf/compiler/csharp/csharp_message.h b/src/google/protobuf/compiler/csharp/csharp_message.h index 8174023b3b..7e88ecf132 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.h +++ b/src/google/protobuf/compiler/csharp/csharp_message.h @@ -50,6 +50,9 @@ class MessageGenerator : public SourceGeneratorBase { MessageGenerator(const Descriptor* descriptor, const Options* options); ~MessageGenerator(); + MessageGenerator(const MessageGenerator&) = delete; + MessageGenerator& operator=(const MessageGenerator&) = delete; + void GenerateCloningCode(io::Printer* printer); void GenerateFreezingCode(io::Printer* printer); void GenerateFrameworkMethods(io::Printer* printer); @@ -78,8 +81,6 @@ class MessageGenerator : public SourceGeneratorBase { // field descriptors sorted by number const std::vector& fields_by_number(); - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator); }; } // namespace csharp diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_message_field.cc index 670c1be974..ab76552d13 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.cc @@ -31,7 +31,6 @@ #include #include -#include #include #include #include diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.h b/src/google/protobuf/compiler/csharp/csharp_message_field.h index 104fb02785..224bc28ead 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.h @@ -48,6 +48,9 @@ class MessageFieldGenerator : public FieldGeneratorBase { const Options *options); ~MessageFieldGenerator(); + MessageFieldGenerator(const MessageFieldGenerator&) = delete; + MessageFieldGenerator& operator=(const MessageFieldGenerator&) = delete; + virtual void GenerateCodecCode(io::Printer* printer); virtual void GenerateCloningCode(io::Printer* printer); virtual void GenerateFreezingCode(io::Printer* printer); @@ -60,9 +63,6 @@ class MessageFieldGenerator : public FieldGeneratorBase { virtual void WriteHash(io::Printer* printer); virtual void WriteEquals(io::Printer* printer); virtual void WriteToString(io::Printer* printer); - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator); }; class MessageOneofFieldGenerator : public MessageFieldGenerator { @@ -72,14 +72,15 @@ class MessageOneofFieldGenerator : public MessageFieldGenerator { const Options *options); ~MessageOneofFieldGenerator(); + MessageOneofFieldGenerator(const MessageOneofFieldGenerator&) = delete; + MessageOneofFieldGenerator& operator=(const MessageOneofFieldGenerator&) = + delete; + virtual void GenerateCloningCode(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer); virtual void GenerateMergingCode(io::Printer* printer); virtual void WriteToString(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageOneofFieldGenerator); }; } // namespace csharp diff --git a/src/google/protobuf/compiler/csharp/csharp_names.h b/src/google/protobuf/compiler/csharp/csharp_names.h index 87a16515d7..0c5ade919f 100644 --- a/src/google/protobuf/compiler/csharp/csharp_names.h +++ b/src/google/protobuf/compiler/csharp/csharp_names.h @@ -91,10 +91,10 @@ string PROTOC_EXPORT GetReflectionClassName(const FileDescriptor* descriptor); // The file name to use as output file for given file descriptor. In case // of failure, this function will return empty string and error parameter // will contain the error message. -string PROTOC_EXPORT -GetOutputFile(const google::protobuf::FileDescriptor* descriptor, - const string file_extension, const bool generate_directories, - const string base_namespace, string* error); +string PROTOC_EXPORT GetOutputFile(const FileDescriptor* descriptor, + const string file_extension, + const bool generate_directories, + const string base_namespace, string* error); } // namespace csharp } // namespace compiler diff --git a/src/google/protobuf/compiler/csharp/csharp_options.h b/src/google/protobuf/compiler/csharp/csharp_options.h index 9629052340..42ff6d8662 100644 --- a/src/google/protobuf/compiler/csharp/csharp_options.h +++ b/src/google/protobuf/compiler/csharp/csharp_options.h @@ -33,7 +33,6 @@ #include -#include namespace google { namespace protobuf { namespace compiler { @@ -49,7 +48,7 @@ struct Options { serializable(false) { } // Extension of the generated file. Defaults to ".cs" - string file_extension; + std::string file_extension; // Base namespace to use to create directory hierarchy. Defaults to "". // This option allows the simple creation of a conventional C# file layout, // where directories are created relative to a project-specific base @@ -60,7 +59,7 @@ struct Options { // // If no base namespace is specified, all files are generated in the // --csharp_out directory, with no subdirectories created automatically. - string base_namespace; + std::string base_namespace; // Whether the base namespace has been explicitly specified by the user. // This is required as the base namespace can be explicitly set to the empty // string, meaning "create a full directory hierarchy, starting from the first @@ -77,7 +76,6 @@ struct Options { } // namespace csharp } // namespace compiler } // namespace protobuf - - } // namespace google + #endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_OPTIONS_H__ diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc index 87d51a9e95..0bf10f2e96 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -31,7 +31,6 @@ #include #include -#include #include #include #include diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.h b/src/google/protobuf/compiler/csharp/csharp_primitive_field.h index 010ceb2197..54782e15f0 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.h @@ -50,6 +50,9 @@ class PrimitiveFieldGenerator : public FieldGeneratorBase { const Options *options); ~PrimitiveFieldGenerator(); + PrimitiveFieldGenerator(const PrimitiveFieldGenerator&) = delete; + PrimitiveFieldGenerator& operator=(const PrimitiveFieldGenerator&) = delete; + virtual void GenerateCodecCode(io::Printer* printer); virtual void GenerateCloningCode(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer); @@ -64,9 +67,6 @@ class PrimitiveFieldGenerator : public FieldGeneratorBase { protected: bool is_value_type; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveFieldGenerator); }; class PrimitiveOneofFieldGenerator : public PrimitiveFieldGenerator { @@ -76,14 +76,15 @@ class PrimitiveOneofFieldGenerator : public PrimitiveFieldGenerator { const Options *options); ~PrimitiveOneofFieldGenerator(); + PrimitiveOneofFieldGenerator(const PrimitiveOneofFieldGenerator&) = delete; + PrimitiveOneofFieldGenerator& operator=(const PrimitiveOneofFieldGenerator&) = + delete; + virtual void GenerateCloningCode(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer); virtual void GenerateMergingCode(io::Printer* printer); virtual void WriteToString(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveOneofFieldGenerator); }; } // namespace csharp diff --git a/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc b/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc index 5b70f1ac0e..4ed2ef3637 100644 --- a/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc +++ b/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc @@ -31,7 +31,6 @@ #include #include -#include #include #include #include diff --git a/src/google/protobuf/compiler/csharp/csharp_reflection_class.h b/src/google/protobuf/compiler/csharp/csharp_reflection_class.h index 3291d65b06..1a4a2f4a7d 100644 --- a/src/google/protobuf/compiler/csharp/csharp_reflection_class.h +++ b/src/google/protobuf/compiler/csharp/csharp_reflection_class.h @@ -48,6 +48,9 @@ class ReflectionClassGenerator : public SourceGeneratorBase { ReflectionClassGenerator(const FileDescriptor* file, const Options* options); ~ReflectionClassGenerator(); + ReflectionClassGenerator(const ReflectionClassGenerator&) = delete; + ReflectionClassGenerator& operator=(const ReflectionClassGenerator&) = delete; + void Generate(io::Printer* printer); private: @@ -61,8 +64,6 @@ class ReflectionClassGenerator : public SourceGeneratorBase { void WriteGeneratedCodeInfo(const Descriptor* descriptor, io::Printer* printer, bool last); - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ReflectionClassGenerator); }; } // namespace csharp diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc index 845fc2a8ce..b8e66abb2b 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc @@ -31,7 +31,6 @@ #include #include -#include #include #include #include diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h index 58252225cd..75de1adab3 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h @@ -41,8 +41,8 @@ namespace protobuf { namespace compiler { namespace csharp { -// TODO(jonskeet): Refactor repeated field support; all the implementations are *really* similar. We -// should probably have a RepeatedFieldGeneratorBase. +// TODO(jonskeet): Refactor repeated field support; all the implementations are +// *really* similar. We should probably have a RepeatedFieldGeneratorBase. class RepeatedEnumFieldGenerator : public FieldGeneratorBase { public: RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor, @@ -50,6 +50,10 @@ class RepeatedEnumFieldGenerator : public FieldGeneratorBase { const Options *options); ~RepeatedEnumFieldGenerator(); + RepeatedEnumFieldGenerator(const RepeatedEnumFieldGenerator&) = delete; + RepeatedEnumFieldGenerator& operator=(const RepeatedEnumFieldGenerator&) = + delete; + virtual void GenerateCloningCode(io::Printer* printer); virtual void GenerateFreezingCode(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer); @@ -61,9 +65,6 @@ class RepeatedEnumFieldGenerator : public FieldGeneratorBase { virtual void WriteHash(io::Printer* printer); virtual void WriteEquals(io::Printer* printer); virtual void WriteToString(io::Printer* printer); - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedEnumFieldGenerator); }; } // namespace csharp diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc index d42165971e..bf76c0d378 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc @@ -31,7 +31,6 @@ #include #include -#include #include #include #include diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h index ebc760fa62..e1b5f27c17 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h @@ -50,6 +50,10 @@ class RepeatedMessageFieldGenerator : public FieldGeneratorBase { const Options *options); ~RepeatedMessageFieldGenerator(); + RepeatedMessageFieldGenerator(const RepeatedMessageFieldGenerator&) = delete; + RepeatedMessageFieldGenerator& operator=( + const RepeatedMessageFieldGenerator&) = delete; + virtual void GenerateCloningCode(io::Printer* printer); virtual void GenerateFreezingCode(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer); @@ -61,9 +65,6 @@ class RepeatedMessageFieldGenerator : public FieldGeneratorBase { virtual void WriteHash(io::Printer* printer); virtual void WriteEquals(io::Printer* printer); virtual void WriteToString(io::Printer* printer); - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedMessageFieldGenerator); }; } // namespace csharp diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc index bc25627fd6..78fcdc674f 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc @@ -31,7 +31,6 @@ #include #include -#include #include #include #include diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h index 340688eb4e..7d9826fcd9 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h @@ -43,9 +43,13 @@ namespace csharp { class RepeatedPrimitiveFieldGenerator : public FieldGeneratorBase { public: - RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor, int presenceIndex, const Options *options); + RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor, + int presenceIndex, const Options* options); ~RepeatedPrimitiveFieldGenerator(); + RepeatedPrimitiveFieldGenerator(const RepeatedPrimitiveFieldGenerator&) = delete; + RepeatedPrimitiveFieldGenerator& operator=(const RepeatedPrimitiveFieldGenerator&) = delete; + virtual void GenerateCloningCode(io::Printer* printer); virtual void GenerateFreezingCode(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer); @@ -57,9 +61,6 @@ class RepeatedPrimitiveFieldGenerator : public FieldGeneratorBase { virtual void WriteHash(io::Printer* printer); virtual void WriteEquals(io::Printer* printer); virtual void WriteToString(io::Printer* printer); - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPrimitiveFieldGenerator); }; } // namespace csharp diff --git a/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc b/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc index 1fda7ddf31..68209cc825 100644 --- a/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc @@ -31,7 +31,6 @@ #include #include -#include #include #include #include diff --git a/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h b/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h index 790fb1be77..695c4225d3 100644 --- a/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h +++ b/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h @@ -48,6 +48,9 @@ class SourceGeneratorBase { SourceGeneratorBase(const FileDescriptor* descriptor, const Options* options); virtual ~SourceGeneratorBase(); + SourceGeneratorBase(const SourceGeneratorBase&) = delete; + SourceGeneratorBase& operator=(const SourceGeneratorBase&) = delete; + std::string class_access_level(); const Options* options(); @@ -58,8 +61,6 @@ class SourceGeneratorBase { private: const FileDescriptor* descriptor_; const Options *options_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SourceGeneratorBase); }; } // namespace csharp diff --git a/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc b/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc index 1dcbf97bb1..f284763dfd 100644 --- a/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc @@ -31,7 +31,6 @@ #include #include -#include #include #include #include diff --git a/src/google/protobuf/compiler/csharp/csharp_wrapper_field.h b/src/google/protobuf/compiler/csharp/csharp_wrapper_field.h index 08cae548a1..ee684dda7c 100644 --- a/src/google/protobuf/compiler/csharp/csharp_wrapper_field.h +++ b/src/google/protobuf/compiler/csharp/csharp_wrapper_field.h @@ -50,6 +50,9 @@ class WrapperFieldGenerator : public FieldGeneratorBase { const Options *options); ~WrapperFieldGenerator(); + WrapperFieldGenerator(const WrapperFieldGenerator&) = delete; + WrapperFieldGenerator& operator=(const WrapperFieldGenerator&) = delete; + virtual void GenerateCodecCode(io::Printer* printer); virtual void GenerateCloningCode(io::Printer* printer); virtual void GenerateMembers(io::Printer* printer); @@ -64,7 +67,6 @@ class WrapperFieldGenerator : public FieldGeneratorBase { private: bool is_value_type; // True for int32 etc; false for bytes and string - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(WrapperFieldGenerator); }; class WrapperOneofFieldGenerator : public WrapperFieldGenerator { @@ -74,14 +76,14 @@ class WrapperOneofFieldGenerator : public WrapperFieldGenerator { const Options *options); ~WrapperOneofFieldGenerator(); + WrapperOneofFieldGenerator(const WrapperOneofFieldGenerator&) = delete; + WrapperOneofFieldGenerator& operator=(const WrapperOneofFieldGenerator&) = delete; + virtual void GenerateMembers(io::Printer* printer); virtual void GenerateMergingCode(io::Printer* printer); virtual void GenerateParsingCode(io::Printer* printer); virtual void GenerateSerializationCode(io::Printer* printer); virtual void GenerateSerializedSizeCode(io::Printer* printer); - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(WrapperOneofFieldGenerator); }; } // namespace csharp diff --git a/src/google/protobuf/compiler/java/java_helpers.cc b/src/google/protobuf/compiler/java/java_helpers.cc index fa9e69348e..3b397d3fe0 100644 --- a/src/google/protobuf/compiler/java/java_helpers.cc +++ b/src/google/protobuf/compiler/java/java_helpers.cc @@ -105,21 +105,6 @@ std::string FieldName(const FieldDescriptor* field) { return field_name; } - -// Judge whether should use table or use look up. -// Copied from com.google.protobuf.SchemaUtil.shouldUseTableSwitch -bool ShouldUseTable(int lo, int hi, int number_of_fields) { - if (hi < kDefaultLookUpStartFieldNumber) { - return true; - } - int64 table_space_cost = (static_cast(hi) - lo + 1); // words - int64 table_time_cost = 3; // comparisons - int64 lookup_space_cost = 3 + 2 * static_cast(number_of_fields); - int64 lookup_time_cost = 3 + number_of_fields; - return table_space_cost + 3 * table_time_cost <= - lookup_space_cost + 3 * lookup_time_cost; -} - } // namespace void PrintGeneratedAnnotation(io::Printer* printer, char delimiter, diff --git a/src/google/protobuf/compiler/php/php_generator.h b/src/google/protobuf/compiler/php/php_generator.h index 1b6f471a6f..ef708ab56d 100644 --- a/src/google/protobuf/compiler/php/php_generator.h +++ b/src/google/protobuf/compiler/php/php_generator.h @@ -43,8 +43,7 @@ namespace protobuf { namespace compiler { namespace php { -class PROTOC_EXPORT Generator - : public PROTOBUF_NAMESPACE_ID::compiler::CodeGenerator { +class PROTOC_EXPORT Generator : public CodeGenerator { virtual bool Generate( const FileDescriptor* file, const string& parameter, @@ -55,12 +54,9 @@ class PROTOC_EXPORT Generator // To skip reserved keywords in php, some generated classname are prefixed. // Other code generators may need following API to figure out the actual // classname. -PROTOC_EXPORT std::string GeneratedClassName( - const PROTOBUF_NAMESPACE_ID::Descriptor* desc); -PROTOC_EXPORT std::string GeneratedClassName( - const PROTOBUF_NAMESPACE_ID::EnumDescriptor* desc); -PROTOC_EXPORT std::string GeneratedClassName( - const PROTOBUF_NAMESPACE_ID::ServiceDescriptor* desc); +PROTOC_EXPORT std::string GeneratedClassName(const Descriptor* desc); +PROTOC_EXPORT std::string GeneratedClassName(const EnumDescriptor* desc); +PROTOC_EXPORT std::string GeneratedClassName(const ServiceDescriptor* desc); inline bool IsWrapperType(const FieldDescriptor* descriptor) { return descriptor->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && diff --git a/src/google/protobuf/compiler/ruby/ruby_generator.cc b/src/google/protobuf/compiler/ruby/ruby_generator.cc index 1079dc319e..23091c8f4f 100644 --- a/src/google/protobuf/compiler/ruby/ruby_generator.cc +++ b/src/google/protobuf/compiler/ruby/ruby_generator.cc @@ -46,25 +46,19 @@ namespace compiler { namespace ruby { // Forward decls. -template std::string NumberToString(numeric_type value); +template +std::string NumberToString(numeric_type value); std::string GetRequireName(const std::string& proto_file); -std::string LabelForField(google::protobuf::FieldDescriptor* field); -std::string TypeName(google::protobuf::FieldDescriptor* field); -bool GenerateMessage(const google::protobuf::Descriptor* message, - google::protobuf::io::Printer* printer, - std::string* error); -void GenerateEnum(const google::protobuf::EnumDescriptor* en, - google::protobuf::io::Printer* printer); -void GenerateMessageAssignment( - const std::string& prefix, - const google::protobuf::Descriptor* message, - google::protobuf::io::Printer* printer); -void GenerateEnumAssignment( - const std::string& prefix, - const google::protobuf::EnumDescriptor* en, - google::protobuf::io::Printer* printer); -std::string DefaultValueForField( - const google::protobuf::FieldDescriptor* field); +std::string LabelForField(FieldDescriptor* field); +std::string TypeName(FieldDescriptor* field); +bool GenerateMessage(const Descriptor* message, io::Printer* printer, + std::string* error); +void GenerateEnum(const EnumDescriptor* en, io::Printer* printer); +void GenerateMessageAssignment(const std::string& prefix, + const Descriptor* message, io::Printer* printer); +void GenerateEnumAssignment(const std::string& prefix, const EnumDescriptor* en, + io::Printer* printer); +std::string DefaultValueForField(const FieldDescriptor* field); template std::string NumberToString(numeric_type value) { @@ -82,7 +76,7 @@ std::string GetOutputFilename(const std::string& proto_file) { return GetRequireName(proto_file) + ".rb"; } -std::string LabelForField(const google::protobuf::FieldDescriptor* field) { +std::string LabelForField(const FieldDescriptor* field) { switch (field->label()) { case FieldDescriptor::LABEL_OPTIONAL: return "optional"; case FieldDescriptor::LABEL_REQUIRED: return "required"; @@ -91,7 +85,7 @@ std::string LabelForField(const google::protobuf::FieldDescriptor* field) { } } -std::string TypeName(const google::protobuf::FieldDescriptor* field) { +std::string TypeName(const FieldDescriptor* field) { switch (field->type()) { case FieldDescriptor::TYPE_INT32: return "int32"; case FieldDescriptor::TYPE_INT64: return "int64"; @@ -124,12 +118,12 @@ string StringifySyntax(FileDescriptor::Syntax syntax) { case FileDescriptor::SYNTAX_UNKNOWN: default: GOOGLE_LOG(FATAL) << "Unsupported syntax; this generator only supports " - "proto2 and proto3 syntax."; + "proto2 and proto3 syntax."; return ""; } } -std::string DefaultValueForField(const google::protobuf::FieldDescriptor* field) { +std::string DefaultValueForField(const FieldDescriptor* field) { switch(field->cpp_type()) { case FieldDescriptor::CPPTYPE_INT32: return NumberToString(field->default_value_int32()); @@ -160,7 +154,7 @@ std::string DefaultValueForField(const google::protobuf::FieldDescriptor* field) for (int i = 0; i < default_str.length(); ++i) { // Write the hex form of each byte. os << "\\x" << std::hex << std::setw(2) - << ((uint16) ((unsigned char) default_str.at(i))); + << ((uint16)((unsigned char)default_str.at(i))); } os << "\".force_encoding(\"ASCII-8BIT\")"; } @@ -171,9 +165,7 @@ std::string DefaultValueForField(const google::protobuf::FieldDescriptor* field) } } -void GenerateField(const google::protobuf::FieldDescriptor* field, - google::protobuf::io::Printer* printer) { - +void GenerateField(const FieldDescriptor* field, io::Printer* printer) { if (field->is_map()) { const FieldDescriptor* key_field = field->message_type()->FindFieldByNumber(1); @@ -220,17 +212,15 @@ void GenerateField(const google::protobuf::FieldDescriptor* field, } if (field->has_default_value()) { - printer->Print( - ", default: $default$", - "default", DefaultValueForField(field)); + printer->Print(", default: $default$", "default", + DefaultValueForField(field)); } printer->Print("\n"); } } -void GenerateOneof(const google::protobuf::OneofDescriptor* oneof, - google::protobuf::io::Printer* printer) { +void GenerateOneof(const OneofDescriptor* oneof, io::Printer* printer) { printer->Print( "oneof :$name$ do\n", "name", oneof->name()); @@ -245,9 +235,8 @@ void GenerateOneof(const google::protobuf::OneofDescriptor* oneof, printer->Print("end\n"); } -bool GenerateMessage(const google::protobuf::Descriptor* message, - google::protobuf::io::Printer* printer, - std::string* error) { +bool GenerateMessage(const Descriptor* message, io::Printer* printer, + std::string* error) { if (message->extension_range_count() > 0 || message->extension_count() > 0) { *error = "Extensions are not yet supported for proto2 .proto files."; return false; @@ -291,8 +280,7 @@ bool GenerateMessage(const google::protobuf::Descriptor* message, return true; } -void GenerateEnum(const google::protobuf::EnumDescriptor* en, - google::protobuf::io::Printer* printer) { +void GenerateEnum(const EnumDescriptor* en, io::Printer* printer) { printer->Print( "add_enum \"$name$\" do\n", "name", en->full_name()); @@ -318,7 +306,7 @@ bool IsUpper(char ch) { return ch >= 'A' && ch <= 'Z'; } bool IsAlpha(char ch) { return IsLower(ch) || IsUpper(ch); } -char ToUpper(char ch) { return IsLower(ch) ? (ch - 'a' + 'A') : ch; } +char UpperChar(char ch) { return IsLower(ch) ? (ch - 'a' + 'A') : ch; } // Package names in protobuf are snake_case by convention, but Ruby module @@ -335,7 +323,7 @@ std::string PackageToModule(const std::string& name) { next_upper = true; } else { if (next_upper) { - result.push_back(ToUpper(name[i])); + result.push_back(UpperChar(name[i])); } else { result.push_back(name[i]); } @@ -355,7 +343,7 @@ std::string RubifyConstant(const std::string& name) { if (!ret.empty()) { if (IsLower(ret[0])) { // If it starts with a lowercase letter, capitalize it. - ret[0] = ToUpper(ret[0]); + ret[0] = UpperChar(ret[0]); } else if (!IsAlpha(ret[0])) { // Otherwise (e.g. if it begins with an underscore), we need to come up // with some prefix that starts with a capital letter. We could be smarter @@ -369,11 +357,9 @@ std::string RubifyConstant(const std::string& name) { return ret; } -void GenerateMessageAssignment( - const std::string& prefix, - const google::protobuf::Descriptor* message, - google::protobuf::io::Printer* printer) { - +void GenerateMessageAssignment(const std::string& prefix, + const Descriptor* message, + io::Printer* printer) { // Don't generate MapEntry messages -- we use the Ruby extension's native // support for map fields instead. if (message->options().map_entry()) { @@ -398,10 +384,8 @@ void GenerateMessageAssignment( } } -void GenerateEnumAssignment( - const std::string& prefix, - const google::protobuf::EnumDescriptor* en, - google::protobuf::io::Printer* printer) { +void GenerateEnumAssignment(const std::string& prefix, const EnumDescriptor* en, + io::Printer* printer) { printer->Print( "$prefix$$name$ = ", "prefix", prefix, @@ -412,9 +396,7 @@ void GenerateEnumAssignment( "full_name", en->full_name()); } -int GeneratePackageModules( - const FileDescriptor* file, - google::protobuf::io::Printer* printer) { +int GeneratePackageModules(const FileDescriptor* file, io::Printer* printer) { int levels = 0; bool need_change_to_module = true; std::string package_name; @@ -466,9 +448,7 @@ int GeneratePackageModules( return levels; } -void EndPackageModules( - int levels, - google::protobuf::io::Printer* printer) { +void EndPackageModules(int levels, io::Printer* printer) { while (levels > 0) { levels--; printer->Outdent(); diff --git a/src/google/protobuf/compiler/ruby/ruby_generator.h b/src/google/protobuf/compiler/ruby/ruby_generator.h index 5fac830f6f..731a81a52d 100644 --- a/src/google/protobuf/compiler/ruby/ruby_generator.h +++ b/src/google/protobuf/compiler/ruby/ruby_generator.h @@ -48,8 +48,7 @@ namespace ruby { // If you create your own protocol compiler binary and you want it to support // Ruby output, you can do so by registering an instance of this // CodeGenerator with the CommandLineInterface in your main() function. -class PROTOC_EXPORT Generator - : public PROTOBUF_NAMESPACE_ID::compiler::CodeGenerator { +class PROTOC_EXPORT Generator : public CodeGenerator { virtual bool Generate( const FileDescriptor* file, const string& parameter,