parameters: (self, elem, needsNum, bitwidth = 32, forceSuffix = False)
return_statement: return [None, None]
docstring: Parse and convert an `<enum>` tag into a value.
  
          Returns a list:
  
          - first element - integer representation of the value, or None
            if needsNum is False. The value must be a legal number
            if needsNum is True.
          - second element - string representation of the value
  
          There are several possible representations of values.
  
          - A 'value' attribute simply contains the value.
          - A 'bitpos' attribute defines a value by specifying the bit
            position which is set in that value.
          - An 'offset','extbase','extends' triplet specifies a value
            as an offset to a base value defined by the specified
            'extbase' extension name, which is then cast to the
            typename specified by 'extends'. This requires probing
            the registry database, and imbeds knowledge of the
            API extension enum scheme in this function.
          - An 'alias' attribute contains the name of another enum
            which this is an alias of. The other enum must be
            declared first when emitting this enum.
docstring_summary: Parse and convert an `<enum>` tag into a value.
docstring_tokens: Parse and convert an <enum > tag into a value .
function: def enumToValue(self, elem, needsNum, bitwidth = 32, forceSuffix = False):
          """Parse and convert an `<enum>` tag into a value.
  
          Returns a list:
  
          - first element - integer representation of the value, or None
            if needsNum is False. The value must be a legal number
            if needsNum is True.
          - second element - string representation of the value
  
          There are several possible representations of values.
  
          - A 'value' attribute simply contains the value.
          - A 'bitpos' attribute defines a value by specifying the bit
            position which is set in that value.
          - An 'offset','extbase','extends' triplet specifies a value
            as an offset to a base value defined by the specified
            'extbase' extension name, which is then cast to the
            typename specified by 'extends'. This requires probing
            the registry database, and imbeds knowledge of the
            API extension enum scheme in this function.
          - An 'alias' attribute contains the name of another enum
            which this is an alias of. The other enum must be
            declared first when emitting this enum."""
          name = elem.get('name')
          numVal = None
          if 'value' in elem.keys():
              value = elem.get('value')
              # print('About to translate value =', value, 'type =', type(value))
              if needsNum:
                  numVal = int(value, 0)
              # If there's a non-integer, numeric 'type' attribute (e.g. 'u' or
              # 'ull'), append it to the string value.
              # t = enuminfo.elem.get('type')
              # if t is not None and t != '' and t != 'i' and t != 's':
              #     value += enuminfo.type
              if forceSuffix:
                if bitwidth == 64:
                  value = value + 'ULL'
                else:
                  value = value + 'U'
              self.logMsg('diag', 'Enum', name, '-> value [', numVal, ',', value, ']')
              return [numVal, value]
          if 'bitpos' in elem.keys():
              value = elem.get('bitpos')
              bitpos = int(value, 0)
              numVal = 1 << bitpos
              value = '0x%08x' % numVal
              if bitwidth == 64:
                value = value + 'ULL'
              elif forceSuffix:
                value = value + 'U'
              self.logMsg('diag', 'Enum', name, '-> bitpos [', numVal, ',', value, ']')
              return [numVal, value]
          if 'offset' in elem.keys():
              # Obtain values in the mapping from the attributes
              enumNegative = False
              offset = int(elem.get('offset'), 0)
              extnumber = int(elem.get('extnumber'), 0)
              extends = elem.get('extends')
              if 'dir' in elem.keys():
                  enumNegative = True
              self.logMsg('diag', 'Enum', name, 'offset =', offset,
                          'extnumber =', extnumber, 'extends =', extends,
                          'enumNegative =', enumNegative)
              # Now determine the actual enumerant value, as defined
              # in the "Layers and Extensions" appendix of the spec.
              numVal = self.extBase + (extnumber - 1) * self.extBlockSize + offset
              if enumNegative:
                  numVal *= -1
              value = '%d' % numVal
              # More logic needed!
              self.logMsg('diag', 'Enum', name, '-> offset [', numVal, ',', value, ']')
              return [numVal, value]
          if 'alias' in elem.keys():
              return [None, elem.get('alias')]
          return [None, None]
function_tokens: def enumToValue ( self , elem , needsNum , bitwidth = 32 , forceSuffix = False ) : name = elem . get ( 'name' ) numVal = None if 'value' in elem . keys ( ) : value = elem . get ( 'value' ) # print('About to translate value =', value, 'type =', type(value)) if needsNum : numVal = int ( value , 0 ) # If there's a non-integer, numeric 'type' attribute (e.g. 'u' or # 'ull'), append it to the string value. # t = enuminfo.elem.get('type') # if t is not None and t != '' and t != 'i' and t != 's': #     value += enuminfo.type if forceSuffix : if bitwidth == 64 : value = value + 'ULL' else : value = value + 'U' self . logMsg ( 'diag' , 'Enum' , name , '-> value [' , numVal , ',' , value , ']' ) return [ numVal , value ] if 'bitpos' in elem . keys ( ) : value = elem . get ( 'bitpos' ) bitpos = int ( value , 0 ) numVal = 1 << bitpos value = '0x%08x' % numVal if bitwidth == 64 : value = value + 'ULL' elif forceSuffix : value = value + 'U' self . logMsg ( 'diag' , 'Enum' , name , '-> bitpos [' , numVal , ',' , value , ']' ) return [ numVal , value ] if 'offset' in elem . keys ( ) : # Obtain values in the mapping from the attributes enumNegative = False offset = int ( elem . get ( 'offset' ) , 0 ) extnumber = int ( elem . get ( 'extnumber' ) , 0 ) extends = elem . get ( 'extends' ) if 'dir' in elem . keys ( ) : enumNegative = True self . logMsg ( 'diag' , 'Enum' , name , 'offset =' , offset , 'extnumber =' , extnumber , 'extends =' , extends , 'enumNegative =' , enumNegative ) # Now determine the actual enumerant value, as defined # in the "Layers and Extensions" appendix of the spec. numVal = self . extBase + ( extnumber - 1 ) * self . extBlockSize + offset if enumNegative : numVal *= - 1 value = '%d' % numVal # More logic needed! self . logMsg ( 'diag' , 'Enum' , name , '-> offset [' , numVal , ',' , value , ']' ) return [ numVal , value ] if 'alias' in elem . keys ( ) : return [ None , elem . get ( 'alias' ) ] return [ None , None ]