Ejemplo n.º 1
0
  def __init__(self, name, package, options=none, serialized_pb=none):
    """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):
      if api_implementation.version() == 2:
        _message.buildfile(self.serialized_pb)
      else:
        cpp_message.buildfile(self.serialized_pb)
Ejemplo n.º 2
0
  def __init__(self, name, full_name, index, number, type, cpp_type, label,
               default_value, message_type, enum_type, containing_type,
               is_extension, extension_scope, options=none,
               has_default_value=true):
    """the arguments are as described in the description of fielddescriptor
    attributes above.

    note that containing_type may be none, and may be set later if necessary
    (to deal with circular references between message types, for example).
    likewise for extension_scope.
    """
    super(fielddescriptor, self).__init__(options, 'fieldoptions')
    self.name = name
    self.full_name = full_name
    self.index = index
    self.number = number
    self.type = type
    self.cpp_type = cpp_type
    self.label = label
    self.has_default_value = has_default_value
    self.default_value = default_value
    self.containing_type = containing_type
    self.message_type = message_type
    self.enum_type = enum_type
    self.is_extension = is_extension
    self.extension_scope = extension_scope
    if api_implementation.type() == 'cpp':
      if is_extension:
        if api_implementation.version() == 2:
          self._cdescriptor = _message.getextensiondescriptor(full_name)
        else:
          self._cdescriptor = cpp_message.getextensiondescriptor(full_name)
      else:
        if api_implementation.version() == 2:
          self._cdescriptor = _message.getfielddescriptor(full_name)
        else:
          self._cdescriptor = cpp_message.getfielddescriptor(full_name)
    else:
      self._cdescriptor = none
 def testimplementationsetting(self):
   self.assertequal('cpp', api_implementation.type())
Ejemplo n.º 4
0
the upshot of all this is that the real implementation
details for all pure-python protocol buffers are *here in
this file*.
"""

__author__ = '[email protected] (will robinson)'


from google.protobuf.internal import api_implementation
from google.protobuf import descriptor as descriptor_mod
from google.protobuf import message

_fielddescriptor = descriptor_mod.fielddescriptor


if api_implementation.type() == 'cpp':
  if api_implementation.version() == 2:
    from google.protobuf.internal.cpp import cpp_message
    _newmessage = cpp_message.newmessage
    _initmessage = cpp_message.initmessage
  else:
    from google.protobuf.internal import cpp_message
    _newmessage = cpp_message.newmessage
    _initmessage = cpp_message.initmessage
else:
  from google.protobuf.internal import python_message
  _newmessage = python_message.newmessage
  _initmessage = python_message.initmessage


class generatedprotocolmessagetype(type):