diff options
author | Feng Xiao <xfxyjwf@gmail.com> | 2015-08-25 20:24:43 -0700 |
---|---|---|
committer | Feng Xiao <xfxyjwf@gmail.com> | 2015-08-25 20:24:43 -0700 |
commit | b192ba87f72b5e3e8add09bbcbb7623831e3079b (patch) | |
tree | affb3beff3c33050e7f93647ddab8606899ff03d /src/google/protobuf/compiler | |
parent | 5da0b46811a103bd1a953f496d4bcd5ff45d3736 (diff) | |
parent | cf94f7b74495d08b833056016e045a0ae3fb64fa (diff) | |
download | protobuf-b192ba87f72b5e3e8add09bbcbb7623831e3079b.tar.gz protobuf-b192ba87f72b5e3e8add09bbcbb7623831e3079b.tar.bz2 protobuf-b192ba87f72b5e3e8add09bbcbb7623831e3079b.zip |
Merge remote-tracking branch 'origin/master' into beta-1
Diffstat (limited to 'src/google/protobuf/compiler')
-rw-r--r-- | src/google/protobuf/compiler/csharp/csharp_helpers.cc | 6 | ||||
-rw-r--r-- | src/google/protobuf/compiler/csharp/csharp_helpers.h | 7 | ||||
-rw-r--r-- | src/google/protobuf/compiler/python/python_generator.cc | 20 |
3 files changed, 13 insertions, 20 deletions
diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc index d25dcba9..333b4912 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc @@ -118,6 +118,12 @@ std::string GetFileNamespace(const FileDescriptor* descriptor) { } std::string GetUmbrellaClassUnqualifiedName(const FileDescriptor* descriptor) { + // We manually rename Descriptor to DescriptorProtoFile to avoid collisions with + // the static Descriptor property. It would be nice to be able to do this with an + // option, but it would be rarely used. + if (IsDescriptorProto(descriptor)) { + return "DescriptorProtoFile"; + } // umbrella_classname can no longer be set using message option. std::string proto_file = descriptor->name(); int lastslash = proto_file.find_last_of("/"); diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.h b/src/google/protobuf/compiler/csharp/csharp_helpers.h index 278e05f3..4ed17a84 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.h +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.h @@ -115,12 +115,7 @@ inline bool IsMapEntryMessage(const Descriptor* descriptor) { // for use in the runtime. This is the only type which is allowed to use proto2 syntax, // and it generates internal classes. inline bool IsDescriptorProto(const FileDescriptor* descriptor) { - // TODO: Do this better! (Currently this depends on a hack in generate_protos.sh to rename - // the file...) - // We need to be able to detect the "normal" name as well, for times that we're just - // depending on descriptor.proto instead of generating it. - return descriptor->name() == "google/protobuf/descriptor_proto_file.proto" - || descriptor->name() == "google/protobuf/descriptor.proto"; + return descriptor->name() == "google/protobuf/descriptor.proto"; } inline bool IsWrapperType(const FieldDescriptor* descriptor) { diff --git a/src/google/protobuf/compiler/python/python_generator.cc b/src/google/protobuf/compiler/python/python_generator.cc index 4d500f90..e81af700 100644 --- a/src/google/protobuf/compiler/python/python_generator.cc +++ b/src/google/protobuf/compiler/python/python_generator.cc @@ -28,7 +28,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -//#PY25 compatible generated code for GAE. // Copyright 2007 Google Inc. All Rights Reserved. // Author: robinson@google.com (Will Robinson) // @@ -167,7 +166,6 @@ void PrintTopBoilerplate( printer->Print( "# Generated by the protocol buffer compiler. DO NOT EDIT!\n" "# source: $filename$\n" - "\nimport sys\n_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))" //##PY25 "\n", "filename", file->name()); if (HasTopLevelEnums(file)) { @@ -259,12 +257,9 @@ string StringifyDefaultValue(const FieldDescriptor& field) { case FieldDescriptor::CPPTYPE_ENUM: return SimpleItoa(field.default_value_enum()->number()); case FieldDescriptor::CPPTYPE_STRING: -//##!PY25 return "b\"" + CEscape(field.default_value_string()) + -//##!PY25 (field.type() != FieldDescriptor::TYPE_STRING ? "\"" : -//##!PY25 "\".decode('utf-8')"); - return "_b(\"" + CEscape(field.default_value_string()) + //##PY25 - (field.type() != FieldDescriptor::TYPE_STRING ? "\")" : //##PY25 - "\").decode('utf-8')"); //##PY25 + return "b\"" + CEscape(field.default_value_string()) + + (field.type() != FieldDescriptor::TYPE_STRING ? "\"" : + "\".decode('utf-8')"); case FieldDescriptor::CPPTYPE_MESSAGE: return "None"; } @@ -390,8 +385,7 @@ void Generator::PrintFileDescriptor() const { printer_->Print(m, file_descriptor_template); printer_->Indent(); printer_->Print( -//##!PY25 "serialized_pb=b'$value$'\n", - "serialized_pb=_b('$value$')\n", //##PY25 + "serialized_pb=b'$value$'\n", "value", strings::CHexEscape(file_descriptor_serialized_)); if (file_->dependency_count() != 0) { printer_->Print(",\ndependencies=["); @@ -1035,10 +1029,8 @@ string Generator::OptionsValue( return "None"; } else { string full_class_name = "descriptor_pb2." + class_name; -//##!PY25 return "_descriptor._ParseOptions(" + full_class_name + "(), b'" -//##!PY25 + CEscape(serialized_options)+ "')"; - return "_descriptor._ParseOptions(" + full_class_name + "(), _b('" //##PY25 - + CEscape(serialized_options)+ "'))"; //##PY25 + return "_descriptor._ParseOptions(" + full_class_name + "(), b'" + + CEscape(serialized_options)+ "')"; } } |