Selaa lähdekoodia

Rename "umbrella" to "reflection" consistently.

This changes csharp_names.h, which will require a corresponding change in GRPC.
Jon Skeet 10 vuotta sitten
vanhempi
commit
a6361a124a

+ 1 - 1
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",

+ 1 - 1
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

+ 2 - 2
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
 

+ 3 - 3
src/google/protobuf/compiler/csharp/csharp_generator.cc

@@ -41,7 +41,7 @@
 #include <google/protobuf/compiler/csharp/csharp_generator.h>
 #include <google/protobuf/compiler/csharp/csharp_helpers.h>
 #include <google/protobuf/compiler/csharp/csharp_names.h>
-#include <google/protobuf/compiler/csharp/csharp_umbrella_class.h>
+#include <google/protobuf/compiler/csharp/csharp_reflection_class.h>
 
 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(

+ 3 - 4
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;
 }
 

+ 2 - 6
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);
 

+ 1 - 1
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())

+ 1 - 1
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

+ 15 - 15
src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc → src/google/protobuf/compiler/csharp/csharp_reflection_class.cc

@@ -43,24 +43,24 @@
 #include <google/protobuf/compiler/csharp/csharp_helpers.h>
 #include <google/protobuf/compiler/csharp/csharp_message.h>
 #include <google/protobuf/compiler/csharp/csharp_names.h>
-#include <google/protobuf/compiler/csharp/csharp_umbrella_class.h>
+#include <google/protobuf/compiler/csharp/csharp_reflection_class.h>
 
 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"
     "/// <summary>File descriptor for $file_name$</summary>\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;

+ 8 - 8
src/google/protobuf/compiler/csharp/csharp_umbrella_class.h → 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 <string>
 
@@ -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__