original_docstring: Generate the C declaration for an "enum" that is actually a
          set of flag bits
docstring: Generate the C declaration for an "enum" that is actually a
  set of flag bits
docstring_tokens: Generate the C declaration for an " enum " that is actually a set of flag bits
code: def buildEnumCDecl_BitmaskOrDefine(self, groupinfo, groupName, bitwidth, usedefine):
          """Generate the C declaration for an "enum" that is actually a
          set of flag bits"""
          groupElem = groupinfo.elem
          flagTypeName = groupElem.get('name')
  
          # Prefix
          body = "// Flag bits for " + flagTypeName + "\n"
  
          if bitwidth == 64:
              body += "typedef VkFlags64 %s;\n" % flagTypeName;
          else:
              body += "typedef VkFlags %s;\n" % flagTypeName;
  
          # Maximum allowable value for a flag (unsigned 64-bit integer)
          maxValidValue = 2**(64) - 1
          minValidValue = 0
  
          # Get a list of nested 'enum' tags.
          enums = groupElem.findall('enum')
  
          # Check for and report duplicates, and return a list with them
          # removed.
          enums = self.checkDuplicateEnums(enums)
  
          # Accumulate non-numeric enumerant values separately and append
          # them following the numeric values, to allow for aliases.
          # NOTE: this doesn't do a topological sort yet, so aliases of
          # aliases can still get in the wrong order.
          aliasText = ''
  
          # Loop over the nested 'enum' tags.
          for elem in enums:
              # Convert the value to an integer and use that to track min/max.
              # Values of form -(number) are accepted but nothing more complex.
              # Should catch exceptions here for more complex constructs. Not yet.
              (numVal, strVal) = self.enumToValue(elem, True, bitwidth, True)
              name = elem.get('name')
  
              # Range check for the enum value
              if numVal is not None and (numVal > maxValidValue or numVal < minValidValue):
                  self.logMsg('error', 'Allowable range for flag types in C is [', minValidValue, ',', maxValidValue, '], but', name, 'flag has a value outside of this (', strVal, ')\n')
                  exit(1)
  
              decl = self.genRequirements(name, mustBeFound = False)
  
              if self.isEnumRequired(elem):
                  protect = elem.get('protect')
                  if protect is not None:
                      body += '#ifdef {}\n'.format(protect)
  
                  if usedefine:
                      decl += "#define {} {}\n".format(name, strVal)
                  elif self.misracppstyle():
                      decl += "static constexpr {} {} {{{}}};\n".format(flagTypeName, name, strVal)
                  else:
                      # Some C compilers only allow initializing a 'static const' variable with a literal value.
                      # So initializing an alias from another 'static const' value would fail to compile.
                      # Work around this by chasing the aliases to get the actual value.
                      while numVal is None:
                          alias = self.registry.tree.find("enums/enum[@name='" + strVal + "']")
                          (numVal, strVal) = self.enumToValue(alias, True, bitwidth, True)
                      decl += "static const {} {} = {};\n".format(flagTypeName, name, strVal)
  
                  if numVal is not None:
                      body += decl
                  else:
                      aliasText += decl
  
                  if protect is not None:
                      body += '#endif\n'
  
          # Now append the non-numeric enumerant values
          body += aliasText
  
          # Postfix
  
          return ("bitmask", body)
code_tokens: def buildEnumCDecl_BitmaskOrDefine ( self , groupinfo , groupName , bitwidth , usedefine ) : groupElem = groupinfo . elem flagTypeName = groupElem . get ( 'name' ) body = "// Flag bits for " + flagTypeName + "\n" if bitwidth == 64 : body += "typedef VkFlags64 %s;\n" % flagTypeName ; else : body += "typedef VkFlags %s;\n" % flagTypeName ; maxValidValue = 2 ** ( 64 ) - 1 minValidValue = 0 enums = groupElem . findall ( 'enum' ) enums = self . checkDuplicateEnums ( enums ) aliasText = '' for elem in enums : ( numVal , strVal ) = self . enumToValue ( elem , True , bitwidth , True ) name = elem . get ( 'name' ) if numVal is not None and ( numVal > maxValidValue or numVal < minValidValue ) : self . logMsg ( 'error' , 'Allowable range for flag types in C is [' , minValidValue , ',' , maxValidValue , '], but' , name , 'flag has a value outside of this (' , strVal , ')\n' ) exit ( 1 ) decl = self . genRequirements ( name , mustBeFound = False ) if self . isEnumRequired ( elem ) : protect = elem . get ( 'protect' ) if protect is not None : body += '#ifdef {}\n' . format ( protect ) if usedefine : decl += "#define {} {}\n" . format ( name , strVal ) elif self . misracppstyle ( ) : decl += "static constexpr {} {} {{{}}};\n" . format ( flagTypeName , name , strVal ) else : while numVal is None : alias = self . registry . tree . find ( "enums/enum[@name='" + strVal + "']" ) ( numVal , strVal ) = self . enumToValue ( alias , True , bitwidth , True ) decl += "static const {} {} = {};\n" . format ( flagTypeName , name , strVal ) if numVal is not None : body += decl else : aliasText += decl if protect is not None : body += '#endif\n' body += aliasText return ( "bitmask" , body )
short_docstring: Generate the C declaration for an "enum" that is actually a
  set of flag bits
short_docstring_tokens: Generate the C declaration for an " enum " that is actually a set of flag bits
comment: """Generate the C declaration for an "enum" that is actually a
          set of flag bits"""$SEP$# Prefix$SEP$# Maximum allowable value for a flag (unsigned 64-bit integer)$SEP$# Get a list of nested 'enum' tags.$SEP$# Check for and report duplicates, and return a list with them$SEP$# removed.$SEP$# Accumulate non-numeric enumerant values separately and append$SEP$# them following the numeric values, to allow for aliases.$SEP$# NOTE: this doesn't do a topological sort yet, so aliases of$SEP$# aliases can still get in the wrong order.$SEP$# Loop over the nested 'enum' tags.$SEP$# Convert the value to an integer and use that to track min/max.$SEP$# Values of form -(number) are accepted but nothing more complex.$SEP$# Should catch exceptions here for more complex constructs. Not yet.$SEP$# Range check for the enum value$SEP$# Some C compilers only allow initializing a 'static const' variable with a literal value.$SEP$# So initializing an alias from another 'static const' value would fail to compile.$SEP$# Work around this by chasing the aliases to get the actual value.$SEP$# Now append the non-numeric enumerant values$SEP$# Postfix