(self, prop, schema, api_object)
Common annotations that apply to both parameters and properties.
Common annotations that apply to both parameters and properties.
Common annotations that apply to both parameters and properties .
def AnnotateParameterOrProperty(self, prop, schema, api_object):
    """Common annotations that apply to both parameters and properties."""
    # Property attributes depend on type
    if prop.data_type.code_type == 'NSString':
      prop.SetTemplateValue('attributes', 'nonatomic, copy')
    else:
      prop.SetTemplateValue('attributes', 'nonatomic, retain')

    # Properties starting with certain strings will cause a clang warning about
    # naming conventions unless we add a directive to stop it.
    if self._NOT_RETAINED.match(prop.codeName):
      prop.SetTemplateValue('clangDirective', ' NS_RETURNS_NOT_RETAINED')

    if isinstance(prop.data_type, data_types.ArrayDataType):
      # Add comment showing type of array elements
      prop.SetTemplateValue('typeComment',
                            'of %s' % (prop.data_type['baseType'].code_type))
      prop.SetTemplateValue('elementCodeType',
                            prop.data_type['baseType'].code_type)
      # If there are any array properties then we need to generate an
      # arrayPropertyToClassMap method.
      schema.SetTemplateValue('arrayPropertyToClassMap', True)
      # If it is an array of enum values then we need to handle the enum type.
      enum_values = prop.data_type['baseType'].values.get('enum')
      if enum_values:
        self.AnnotateEnum(api_object, prop, schema, enum_values)
    elif prop.data_type.code_type in ['NSNumber', 'NSString']:
      if prop.data_type.json_format:
        prop.SetTemplateValue(
            'typeComment',
            self._FORMAT_TO_TYPE_COMMENT.get(prop.data_type.json_format))
    elif prop.GetTemplateValue('type'):
      prop.SetTemplateValue('typeComment', prop.GetTemplateValue('type'))

    # We need to generate a propertyToJSONKeyMap if at least one property has a
    # different code name to wire name.
    if prop.codeName != prop.GetTemplateValue('wireName'):
      schema.SetTemplateValue('propertyToJSONKeyMap', True)

    self.AnnotateType(prop.data_type, schema)
def AnnotateParameterOrProperty ( self , prop , schema , api_object ) : # Property attributes depend on type if prop . data_type . code_type == 'NSString' : prop . SetTemplateValue ( 'attributes' , 'nonatomic, copy' ) else : prop . SetTemplateValue ( 'attributes' , 'nonatomic, retain' ) # Properties starting with certain strings will cause a clang warning about # naming conventions unless we add a directive to stop it. if self . _NOT_RETAINED . match ( prop . codeName ) : prop . SetTemplateValue ( 'clangDirective' , ' NS_RETURNS_NOT_RETAINED' ) if isinstance ( prop . data_type , data_types . ArrayDataType ) : # Add comment showing type of array elements prop . SetTemplateValue ( 'typeComment' , 'of %s' % ( prop . data_type [ 'baseType' ] . code_type ) ) prop . SetTemplateValue ( 'elementCodeType' , prop . data_type [ 'baseType' ] . code_type ) # If there are any array properties then we need to generate an # arrayPropertyToClassMap method. schema . SetTemplateValue ( 'arrayPropertyToClassMap' , True ) # If it is an array of enum values then we need to handle the enum type. enum_values = prop . data_type [ 'baseType' ] . values . get ( 'enum' ) if enum_values : self . AnnotateEnum ( api_object , prop , schema , enum_values ) elif prop . data_type . code_type in [ 'NSNumber' , 'NSString' ] : if prop . data_type . json_format : prop . SetTemplateValue ( 'typeComment' , self . _FORMAT_TO_TYPE_COMMENT . get ( prop . data_type . json_format ) ) elif prop . GetTemplateValue ( 'type' ) : prop . SetTemplateValue ( 'typeComment' , prop . GetTemplateValue ( 'type' ) ) # We need to generate a propertyToJSONKeyMap if at least one property has a # different code name to wire name. if prop . codeName != prop . GetTemplateValue ( 'wireName' ) : schema . SetTemplateValue ( 'propertyToJSONKeyMap' , True ) self . AnnotateType ( prop . data_type , schema )