original_docstring: Generate the C declaration for an enum
docstring: Generate the C declaration for an enum
docstring_tokens: Generate the C declaration for an enum
code: def buildEnumCDecl(self, expand, groupinfo, groupName):
          """Generate the C declaration for an enum"""
          groupElem = groupinfo.elem
  
          # Determine the required bit width for the enum group.
          # 32 is the default, which generates C enum types for the values.
          bitwidth = 32
  
          # If the constFlagBits preference is set, 64 is the default for bitmasks
          if self.genOpts.conventions.constFlagBits and groupElem.get('type') == 'bitmask':
              bitwidth = 64
  
          # Check for an explicitly defined bitwidth, which will override any defaults.
          if groupElem.get('bitwidth'):
              try:
                  bitwidth = int(groupElem.get('bitwidth'))
              except ValueError as ve:
                  self.logMsg('error', 'Invalid value for bitwidth attribute (', groupElem.get('bitwidth'), ') for ', groupName, ' - must be an integer value\n')
                  exit(1)
  
          usebitmask = False
          usedefine = False
  
          # Bitmask flags can be generated as either "static const uint{32,64}_t" values,
          # or as 32-bit C enums. 64-bit types must use uint64_t values.
          if groupElem.get('type') == 'bitmask':
              if bitwidth > 32 or self.misracppstyle():
                  usebitmask = True
              if self.misracstyle():
                  usedefine = True
  
          if usedefine or usebitmask:
              # Validate the bitwidth and generate values appropriately
              if bitwidth > 64:
                  self.logMsg('error', 'Invalid value for bitwidth attribute (', groupElem.get('bitwidth'), ') for bitmask type ', groupName, ' - must be less than or equal to 64\n')
                  exit(1)
              else:
                  return self.buildEnumCDecl_BitmaskOrDefine(groupinfo, groupName, bitwidth, usedefine)
          else:
              # Validate the bitwidth and generate values appropriately
              if bitwidth > 32:
                  self.logMsg('error', 'Invalid value for bitwidth attribute (', groupElem.get('bitwidth'), ') for enum type ', groupName, ' - must be less than or equal to 32\n')
                  exit(1)
              else:
                  return self.buildEnumCDecl_Enum(expand, groupinfo, groupName)
code_tokens: def buildEnumCDecl ( self , expand , groupinfo , groupName ) : groupElem = groupinfo . elem bitwidth = 32 if self . genOpts . conventions . constFlagBits and groupElem . get ( 'type' ) == 'bitmask' : bitwidth = 64 if groupElem . get ( 'bitwidth' ) : try : bitwidth = int ( groupElem . get ( 'bitwidth' ) ) except ValueError as ve : self . logMsg ( 'error' , 'Invalid value for bitwidth attribute (' , groupElem . get ( 'bitwidth' ) , ') for ' , groupName , ' - must be an integer value\n' ) exit ( 1 ) usebitmask = False usedefine = False if groupElem . get ( 'type' ) == 'bitmask' : if bitwidth > 32 or self . misracppstyle ( ) : usebitmask = True if self . misracstyle ( ) : usedefine = True if usedefine or usebitmask : if bitwidth > 64 : self . logMsg ( 'error' , 'Invalid value for bitwidth attribute (' , groupElem . get ( 'bitwidth' ) , ') for bitmask type ' , groupName , ' - must be less than or equal to 64\n' ) exit ( 1 ) else : return self . buildEnumCDecl_BitmaskOrDefine ( groupinfo , groupName , bitwidth , usedefine ) else : if bitwidth > 32 : self . logMsg ( 'error' , 'Invalid value for bitwidth attribute (' , groupElem . get ( 'bitwidth' ) , ') for enum type ' , groupName , ' - must be less than or equal to 32\n' ) exit ( 1 ) else : return self . buildEnumCDecl_Enum ( expand , groupinfo , groupName )
short_docstring: Generate the C declaration for an enum
short_docstring_tokens: Generate the C declaration for an enum
comment: """Generate the C declaration for an enum"""$SEP$# Determine the required bit width for the enum group.$SEP$# 32 is the default, which generates C enum types for the values.$SEP$# If the constFlagBits preference is set, 64 is the default for bitmasks$SEP$# Check for an explicitly defined bitwidth, which will override any defaults.$SEP$# Bitmask flags can be generated as either "static const uint{32,64}_t" values,$SEP$# or as 32-bit C enums. 64-bit types must use uint64_t values.$SEP$# Validate the bitwidth and generate values appropriately$SEP$# Validate the bitwidth and generate values appropriately