From a6361a124a6537c69aaaa4e667372ba4e89c1fd1 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Thu, 19 Nov 2015 13:05:17 +0000 Subject: [PATCH] Rename "umbrella" to "reflection" consistently. This changes csharp_names.h, which will require a corresponding change in GRPC. --- BUILD | 2 +- cmake/libprotoc.cmake | 2 +- src/Makefile.am | 4 +-- .../compiler/csharp/csharp_generator.cc | 6 ++-- .../compiler/csharp/csharp_helpers.cc | 7 ++--- .../protobuf/compiler/csharp/csharp_helpers.h | 8 ++--- .../compiler/csharp/csharp_message.cc | 2 +- .../protobuf/compiler/csharp/csharp_names.h | 2 +- ...la_class.cc => csharp_reflection_class.cc} | 30 +++++++++---------- ...ella_class.h => csharp_reflection_class.h} | 16 +++++----- 10 files changed, 37 insertions(+), 42 deletions(-) rename src/google/protobuf/compiler/csharp/{csharp_umbrella_class.cc => csharp_reflection_class.cc} (91%) rename src/google/protobuf/compiler/csharp/{csharp_umbrella_class.h => csharp_reflection_class.h} (84%) diff --git a/BUILD b/BUILD index 7c09605f52..220e5c0f2a 100644 --- a/BUILD +++ b/BUILD @@ -193,11 +193,11 @@ cc_library( "src/google/protobuf/compiler/csharp/csharp_message.cc", "src/google/protobuf/compiler/csharp/csharp_message_field.cc", "src/google/protobuf/compiler/csharp/csharp_primitive_field.cc", + "src/google/protobuf/compiler/csharp/csharp_reflection_class.cc", "src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc", "src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc", "src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc", "src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc", - "src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc", "src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc", "src/google/protobuf/compiler/java/java_context.cc", "src/google/protobuf/compiler/java/java_doc_comment.cc", diff --git a/cmake/libprotoc.cmake b/cmake/libprotoc.cmake index 1ee87b4385..4e628905bb 100644 --- a/cmake/libprotoc.cmake +++ b/cmake/libprotoc.cmake @@ -24,11 +24,11 @@ set(libprotoc_files ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_message.cc ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_message_field.cc ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc + ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc - ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_context.cc ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_doc_comment.cc diff --git a/src/Makefile.am b/src/Makefile.am index 3b66b3da90..b7d6409379 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -453,6 +453,8 @@ libprotoc_la_SOURCES = \ google/protobuf/compiler/csharp/csharp_message_field.h \ google/protobuf/compiler/csharp/csharp_primitive_field.cc \ google/protobuf/compiler/csharp/csharp_primitive_field.h \ + google/protobuf/compiler/csharp/csharp_reflection_class.cc \ + google/protobuf/compiler/csharp/csharp_reflection_class.h \ google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc \ google/protobuf/compiler/csharp/csharp_repeated_enum_field.h \ google/protobuf/compiler/csharp/csharp_repeated_message_field.cc \ @@ -461,8 +463,6 @@ libprotoc_la_SOURCES = \ google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h \ google/protobuf/compiler/csharp/csharp_source_generator_base.cc \ google/protobuf/compiler/csharp/csharp_source_generator_base.h \ - google/protobuf/compiler/csharp/csharp_umbrella_class.cc \ - google/protobuf/compiler/csharp/csharp_umbrella_class.h \ google/protobuf/compiler/csharp/csharp_wrapper_field.cc \ google/protobuf/compiler/csharp/csharp_wrapper_field.h diff --git a/src/google/protobuf/compiler/csharp/csharp_generator.cc b/src/google/protobuf/compiler/csharp/csharp_generator.cc index f5ff880f0d..825de542c3 100644 --- a/src/google/protobuf/compiler/csharp/csharp_generator.cc +++ b/src/google/protobuf/compiler/csharp/csharp_generator.cc @@ -41,7 +41,7 @@ #include #include #include -#include +#include using google::protobuf::internal::scoped_ptr; @@ -52,8 +52,8 @@ namespace csharp { void GenerateFile(const google::protobuf::FileDescriptor* file, io::Printer* printer) { - UmbrellaClassGenerator umbrellaGenerator(file); - umbrellaGenerator.Generate(printer); + ReflectionClassGenerator reflectionClassGenerator(file); + reflectionClassGenerator.Generate(printer); } bool Generator::Generate( diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc index 803e96b744..c51fe44b39 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc @@ -126,8 +126,7 @@ std::string GetFileNameBase(const FileDescriptor* descriptor) { return UnderscoresToPascalCase(StripDotProto(base)); } -std::string GetUmbrellaClassUnqualifiedName(const FileDescriptor* descriptor) { - // umbrella_classname can no longer be set using message option. +std::string GetReflectionClassUnqualifiedName(const FileDescriptor* descriptor) { // TODO: Detect collisions with existing messages, and append an underscore if necessary. return GetFileNameBase(descriptor) + "Reflection"; } @@ -194,12 +193,12 @@ std::string ToCSharpName(const std::string& name, const FileDescriptor* file) { return "global::" + result; } -std::string GetUmbrellaClassName(const FileDescriptor* descriptor) { +std::string GetReflectionClassName(const FileDescriptor* descriptor) { std::string result = GetFileNamespace(descriptor); if (!result.empty()) { result += '.'; } - result += GetUmbrellaClassUnqualifiedName(descriptor); + result += GetReflectionClassUnqualifiedName(descriptor); return "global::" + result; } diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.h b/src/google/protobuf/compiler/csharp/csharp_helpers.h index 4f393e1c05..e96e793887 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.h +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.h @@ -69,12 +69,8 @@ CSharpType GetCSharpType(FieldDescriptor::Type type); std::string StripDotProto(const std::string& proto_file); -// Gets unqualified name of the umbrella class -std::string GetUmbrellaClassUnqualifiedName(const FileDescriptor* descriptor); - -// Gets name of the nested for umbrella class (just the nested part, -// not including the GetFileNamespace part). -std::string GetUmbrellaClassNestedNamespace(const FileDescriptor* descriptor); +// Gets unqualified name of the reflection class +std::string GetReflectionClassUnqualifiedName(const FileDescriptor* descriptor); std::string GetClassName(const EnumDescriptor* descriptor); diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 6cca670322..9c72043bbd 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -119,7 +119,7 @@ void MessageGenerator::Generate(io::Printer* printer) { // Access the message descriptor via the relevant file descriptor or containing message descriptor. if (!descriptor_->containing_type()) { - vars["descriptor_accessor"] = GetUmbrellaClassName(descriptor_->file()) + vars["descriptor_accessor"] = GetReflectionClassName(descriptor_->file()) + ".Descriptor.MessageTypes[" + SimpleItoa(descriptor_->index()) + "]"; } else { vars["descriptor_accessor"] = GetClassName(descriptor_->containing_type()) diff --git a/src/google/protobuf/compiler/csharp/csharp_names.h b/src/google/protobuf/compiler/csharp/csharp_names.h index 23dac1c703..308051871c 100644 --- a/src/google/protobuf/compiler/csharp/csharp_names.h +++ b/src/google/protobuf/compiler/csharp/csharp_names.h @@ -72,7 +72,7 @@ string GetClassName(const Descriptor* descriptor); // The fully-qualified name of the C# class that provides // access to the file descriptor. Proto compiler generates // such class for each .proto file processed. -string GetUmbrellaClassName(const FileDescriptor* descriptor); +string GetReflectionClassName(const FileDescriptor* descriptor); // Generates output file name for given file descriptor. If generate_directories // is true, the output file will be put under directory corresponding to file's diff --git a/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc b/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc similarity index 91% rename from src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc rename to src/google/protobuf/compiler/csharp/csharp_reflection_class.cc index 812c6fc808..7bed02ff0b 100644 --- a/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc +++ b/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc @@ -43,24 +43,24 @@ #include #include #include -#include +#include namespace google { namespace protobuf { namespace compiler { namespace csharp { -UmbrellaClassGenerator::UmbrellaClassGenerator(const FileDescriptor* file) +ReflectionClassGenerator::ReflectionClassGenerator(const FileDescriptor* file) : SourceGeneratorBase(file), file_(file) { namespace_ = GetFileNamespace(file); - umbrellaClassname_ = GetUmbrellaClassUnqualifiedName(file); + reflectionClassname_ = GetReflectionClassUnqualifiedName(file); } -UmbrellaClassGenerator::~UmbrellaClassGenerator() { +ReflectionClassGenerator::~ReflectionClassGenerator() { } -void UmbrellaClassGenerator::Generate(io::Printer* printer) { +void ReflectionClassGenerator::Generate(io::Printer* printer) { WriteIntroduction(printer); WriteDescriptor(printer); @@ -100,7 +100,7 @@ void UmbrellaClassGenerator::Generate(io::Printer* printer) { printer->Print("#endregion Designer generated code\n"); } -void UmbrellaClassGenerator::WriteIntroduction(io::Printer* printer) { +void ReflectionClassGenerator::WriteIntroduction(io::Printer* printer) { printer->Print( "// Generated by the protocol buffer compiler. DO NOT EDIT!\n" "// source: $file_name$\n" @@ -125,14 +125,14 @@ void UmbrellaClassGenerator::WriteIntroduction(io::Printer* printer) { "file_name", file_->name()); WriteGeneratedCodeAttributes(printer); printer->Print( - "$access_level$ static partial class $umbrella_class_name$ {\n" + "$access_level$ static partial class $reflection_class_name$ {\n" "\n", "access_level", class_access_level(), - "umbrella_class_name", umbrellaClassname_); + "reflection_class_name", reflectionClassname_); printer->Indent(); } -void UmbrellaClassGenerator::WriteDescriptor(io::Printer* printer) { +void ReflectionClassGenerator::WriteDescriptor(io::Printer* printer) { printer->Print( "#region Descriptor\n" "/// File descriptor for $file_name$\n" @@ -141,9 +141,9 @@ void UmbrellaClassGenerator::WriteDescriptor(io::Printer* printer) { "}\n" "private static pbr::FileDescriptor descriptor;\n" "\n" - "static $umbrella_class_name$() {\n", + "static $reflection_class_name$() {\n", "file_name", file_->name(), - "umbrella_class_name", umbrellaClassname_); + "reflection_class_name", reflectionClassname_); printer->Indent(); printer->Print( "byte[] descriptorData = global::System.Convert.FromBase64String(\n"); @@ -176,9 +176,9 @@ void UmbrellaClassGenerator::WriteDescriptor(io::Printer* printer) { printer->Print("pbr::FileDescriptor.DescriptorProtoFileDescriptor, "); } else { printer->Print( - "$full_umbrella_class_name$.Descriptor, ", - "full_umbrella_class_name", - GetUmbrellaClassName(file_->dependency(i))); + "$full_reflection_class_name$.Descriptor, ", + "full_reflection_class_name", + GetReflectionClassName(file_->dependency(i))); } } printer->Print("},\n" @@ -226,7 +226,7 @@ void UmbrellaClassGenerator::WriteDescriptor(io::Printer* printer) { // The "last" parameter indicates whether this message descriptor is the last one being printed in this immediate // context. It governs whether or not a trailing comma and newline is written after the constructor, effectively // just controlling the formatting in the generated code. -void UmbrellaClassGenerator::WriteGeneratedCodeInfo(const Descriptor* descriptor, io::Printer* printer, bool last) { +void ReflectionClassGenerator::WriteGeneratedCodeInfo(const Descriptor* descriptor, io::Printer* printer, bool last) { if (IsMapEntryMessage(descriptor)) { printer->Print("null, "); return; diff --git a/src/google/protobuf/compiler/csharp/csharp_umbrella_class.h b/src/google/protobuf/compiler/csharp/csharp_reflection_class.h similarity index 84% rename from src/google/protobuf/compiler/csharp/csharp_umbrella_class.h rename to src/google/protobuf/compiler/csharp/csharp_reflection_class.h index 45a5b7170a..0a5b8ed57a 100644 --- a/src/google/protobuf/compiler/csharp/csharp_umbrella_class.h +++ b/src/google/protobuf/compiler/csharp/csharp_reflection_class.h @@ -28,8 +28,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_UMBRELLA_CLASS_H__ -#define GOOGLE_PROTOBUF_COMPILER_CSHARP_UMBRELLA_CLASS_H__ +#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_REFLECTION_CLASS_H__ +#define GOOGLE_PROTOBUF_COMPILER_CSHARP_REFLECTION_CLASS_H__ #include @@ -41,10 +41,10 @@ namespace protobuf { namespace compiler { namespace csharp { -class UmbrellaClassGenerator : public SourceGeneratorBase { +class ReflectionClassGenerator : public SourceGeneratorBase { public: - UmbrellaClassGenerator(const FileDescriptor* file); - ~UmbrellaClassGenerator(); + ReflectionClassGenerator(const FileDescriptor* file); + ~ReflectionClassGenerator(); void Generate(io::Printer* printer); @@ -52,13 +52,13 @@ class UmbrellaClassGenerator : public SourceGeneratorBase { const FileDescriptor* file_; std::string namespace_; - std::string umbrellaClassname_; + std::string reflectionClassname_; void WriteIntroduction(io::Printer* printer); void WriteDescriptor(io::Printer* printer); void WriteGeneratedCodeInfo(const Descriptor* descriptor, io::Printer* printer, bool last); - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(UmbrellaClassGenerator); + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ReflectionClassGenerator); }; } // namespace csharp @@ -66,4 +66,4 @@ class UmbrellaClassGenerator : public SourceGeneratorBase { } // namespace protobuf } // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_UMBRELLA_CLASS_H__ +#endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_REFLECTION_CLASS_H__