Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Unified Diff: third_party/protobuf/python/google/protobuf/descriptor.py

Issue 6737030: third_party/protobuf: update to upstream r371 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/protobuf/python/google/protobuf/descriptor.py
diff --git a/third_party/protobuf/python/google/protobuf/descriptor.py b/third_party/protobuf/python/google/protobuf/descriptor.py
index aa4ab96953064751d8c242d9045095963aaa21fa..cf609bee88c0430fbc00dddc3d179e9bd80641be 100755
--- a/third_party/protobuf/python/google/protobuf/descriptor.py
+++ b/third_party/protobuf/python/google/protobuf/descriptor.py
@@ -28,16 +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.
-# TODO(robinson): We probably need to provide deep-copy methods for
-# descriptor types. When a FieldDescriptor is passed into
-# Descriptor.__init__(), we should make a deep copy and then set
-# containing_type on it. Alternatively, we could just get
-# rid of containing_type (iit's not needed for reflection.py, at least).
-#
-# TODO(robinson): Print method?
-#
-# TODO(robinson): Useful __repr__?
-
"""Descriptors essentially contain exactly the information found in a .proto
file, in types that make this information accessible in Python.
"""
@@ -45,6 +35,13 @@ file, in types that make this information accessible in Python.
__author__ = 'robinson@google.com (Will Robinson)'
+from google.protobuf.internal import api_implementation
+
+
+if api_implementation.Type() == 'cpp':
+ from google.protobuf.internal import cpp_message
+
+
class Error(Exception):
"""Base error for this module."""
@@ -396,6 +393,13 @@ class FieldDescriptor(DescriptorBase):
self.enum_type = enum_type
self.is_extension = is_extension
self.extension_scope = extension_scope
+ if api_implementation.Type() == 'cpp':
+ if is_extension:
+ self._cdescriptor = cpp_message.GetExtensionDescriptor(full_name)
+ else:
+ self._cdescriptor = cpp_message.GetFieldDescriptor(full_name)
+ else:
+ self._cdescriptor = None
class EnumDescriptor(_NestedDescriptorBase):
@@ -567,9 +571,13 @@ class FileDescriptor(DescriptorBase):
"""Constructor."""
super(FileDescriptor, self).__init__(options, 'FileOptions')
+ self.message_types_by_name = {}
self.name = name
self.package = package
self.serialized_pb = serialized_pb
+ if (api_implementation.Type() == 'cpp' and
+ self.serialized_pb is not None):
+ cpp_message.BuildFile(self.serialized_pb)
def CopyToProto(self, proto):
"""Copies this to a descriptor_pb2.FileDescriptorProto.
« no previous file with comments | « third_party/protobuf/python/ez_setup.py ('k') | third_party/protobuf/python/google/protobuf/internal/api_implementation.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698