def _DefaultValueConstructorForField(field):
 if (field.label == _FieldDescriptor.LABEL_REPEATED):
  if (field.has_default_value and (field.default_value != [])):
   raise ValueError(('Repeated field default value not empty list: %s' % field.default_value))
  if (field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE):
   message_type = field.message_type
   def MakeRepeatedMessageDefault(message):
    return containers.RepeatedCompositeFieldContainer(message._listener_for_children, field.message_type)
   return MakeRepeatedMessageDefault
  else:
   type_checker = type_checkers.GetTypeChecker(field)
   def MakeRepeatedScalarDefault(message):
    return containers.RepeatedScalarFieldContainer(message._listener_for_children, type_checker)
   return MakeRepeatedScalarDefault
 if (field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE):
  message_type = field.message_type
  def MakeSubMessageDefault(message):
   result = message_type._concrete_class()
   result._SetListener(message._listener_for_children)
   return result
  return MakeSubMessageDefault
 def MakeScalarDefault(message):
  return field.default_value
 return MakeScalarDefault

def _DefaultValueConstructorForField ( field ) : if ( field . label == _FieldDescriptor . LABEL_REPEATED ) : if ( field . has_default_value and ( field . default_value != [ ] ) ) : raise ValueError ( ( 'Repeated field default value not empty list: %s' % field . default_value ) ) if ( field . cpp_type == _FieldDescriptor . CPPTYPE_MESSAGE ) : message_type = field . message_type def MakeRepeatedMessageDefault ( message ) : return containers . RepeatedCompositeFieldContainer ( message . _listener_for_children , field . message_type ) return MakeRepeatedMessageDefault else : type_checker = type_checkers . GetTypeChecker ( field ) def MakeRepeatedScalarDefault ( message ) : return containers . RepeatedScalarFieldContainer ( message . _listener_for_children , type_checker ) return MakeRepeatedScalarDefault if ( field . cpp_type == _FieldDescriptor . CPPTYPE_MESSAGE ) : message_type = field . message_type def MakeSubMessageDefault ( message ) : result = message_type . _concrete_class ( ) result . _SetListener ( message . _listener_for_children ) return result return MakeSubMessageDefault def MakeScalarDefault ( message ) : return field . default_value return MakeScalarDefault
returns a function which returns a default value for a field .