parameters: (self)
docstring: Generate interface for specified versions using the current
          generator and generator options
docstring_summary: Generate interface for specified versions using the current
          generator and generator options
docstring_tokens: Generate interface for specified versions using the current generator and generator options
function: def apiGen(self):
          """Generate interface for specified versions using the current
          generator and generator options"""
  
          self.gen.logMsg('diag', '*******************************************')
          self.gen.logMsg('diag', '  Registry.apiGen file:', self.genOpts.filename,
                          'api:', self.genOpts.apiname,
                          'profile:', self.genOpts.profile)
          self.gen.logMsg('diag', '*******************************************')
  
          # Reset required/declared flags for all features
          self.apiReset()
  
          # Compile regexps used to select versions & extensions
          regVersions = re.compile(self.genOpts.versions)
          regEmitVersions = re.compile(self.genOpts.emitversions)
          regAddExtensions = re.compile(self.genOpts.addExtensions)
          regRemoveExtensions = re.compile(self.genOpts.removeExtensions)
          regEmitExtensions = re.compile(self.genOpts.emitExtensions)
          regEmitSpirv = re.compile(self.genOpts.emitSpirv)
  
          # Get all matching API feature names & add to list of FeatureInfo
          # Note we used to select on feature version attributes, not names.
          features = []
          apiMatch = False
          for key in self.apidict:
              fi = self.apidict[key]
              api = fi.elem.get('api')
              if apiNameMatch(self.genOpts.apiname, api):
                  apiMatch = True
                  if regVersions.match(fi.name):
                      # Matches API & version #s being generated. Mark for
                      # emission and add to the features[] list .
                      # @@ Could use 'declared' instead of 'emit'?
                      fi.emit = (regEmitVersions.match(fi.name) is not None)
                      features.append(fi)
                      if not fi.emit:
                          self.gen.logMsg('diag', 'NOT tagging feature api =', api,
                                          'name =', fi.name, 'version =', fi.version,
                                          'for emission (does not match emitversions pattern)')
                      else:
                          self.gen.logMsg('diag', 'Including feature api =', api,
                                          'name =', fi.name, 'version =', fi.version,
                                          'for emission (matches emitversions pattern)')
                  else:
                      self.gen.logMsg('diag', 'NOT including feature api =', api,
                                      'name =', fi.name, 'version =', fi.version,
                                      '(does not match requested versions)')
              else:
                  self.gen.logMsg('diag', 'NOT including feature api =', api,
                                  'name =', fi.name,
                                  '(does not match requested API)')
          if not apiMatch:
              self.gen.logMsg('warn', 'No matching API versions found!')
  
          # Get all matching extensions, in order by their extension number,
          # and add to the list of features.
          # Start with extensions tagged with 'api' pattern matching the API
          # being generated. Add extensions matching the pattern specified in
          # regExtensions, then remove extensions matching the pattern
          # specified in regRemoveExtensions
          for (extName, ei) in sorted(self.extdict.items(), key=lambda x: x[1].number if x[1].number is not None else '0'):
              extName = ei.name
              include = False
  
              # Include extension if defaultExtensions is not None and is
              # exactly matched by the 'supported' attribute.
              if apiNameMatch(self.genOpts.defaultExtensions,
                              ei.elem.get('supported')):
                  self.gen.logMsg('diag', 'Including extension',
                                  extName, "(defaultExtensions matches the 'supported' attribute)")
                  include = True
  
              # Include additional extensions if the extension name matches
              # the regexp specified in the generator options. This allows
              # forcing extensions into an interface even if they're not
              # tagged appropriately in the registry.
              # However we still respect the 'supported' attribute.
              if regAddExtensions.match(extName) is not None:
                  if not apiNameMatch(self.genOpts.apiname, ei.elem.get('supported')):
                      self.gen.logMsg('diag', 'NOT including extension',
                                      extName, '(matches explicitly requested, but does not match the \'supported\' attribute)')
                      include = False
                  else:
                      self.gen.logMsg('diag', 'Including extension',
                                      extName, '(matches explicitly requested extensions to add)')
                      include = True
              # Remove extensions if the name matches the regexp specified
              # in generator options. This allows forcing removal of
              # extensions from an interface even if they're tagged that
              # way in the registry.
              if regRemoveExtensions.match(extName) is not None:
                  self.gen.logMsg('diag', 'Removing extension',
                                  extName, '(matches explicitly requested extensions to remove)')
                  include = False
  
              # If the extension is to be included, add it to the
              # extension features list.
              if include:
                  ei.emit = (regEmitExtensions.match(extName) is not None)
                  features.append(ei)
                  if not ei.emit:
                      self.gen.logMsg('diag', 'NOT tagging extension',
                                      extName,
                                      'for emission (does not match emitextensions pattern)')
  
                  # Hack - can be removed when validity generator goes away
                  # (Jon) I'm not sure what this does, or if it should respect
                  # the ei.emit flag above.
                  self.requiredextensions.append(extName)
              else:
                  self.gen.logMsg('diag', 'NOT including extension',
                                  extName, '(does not match api attribute or explicitly requested extensions)')
  
          # Add all spirv elements to list
          # generators decide to emit them all or not
          # Currently no filtering as no client of these elements needs filtering
          spirvexts = []
          for key in self.spirvextdict:
              si = self.spirvextdict[key]
              si.emit = (regEmitSpirv.match(key) is not None)
              spirvexts.append(si)
          spirvcaps = []
          for key in self.spirvcapdict:
              si = self.spirvcapdict[key]
              si.emit = (regEmitSpirv.match(key) is not None)
              spirvcaps.append(si)
  
          # Sort the features list, if a sort procedure is defined
          if self.genOpts.sortProcedure:
              self.genOpts.sortProcedure(features)
              # print('sortProcedure ->', [f.name for f in features])
  
          # Pass 1: loop over requested API versions and extensions tagging
          #   types/commands/features as required (in an <require> block) or no
          #   longer required (in an <remove> block). It is possible to remove
          #   a feature in one version and restore it later by requiring it in
          #   a later version.
          # If a profile other than 'None' is being generated, it must
          #   match the profile attribute (if any) of the <require> and
          #   <remove> tags.
          self.gen.logMsg('diag', 'PASS 1: TAG FEATURES')
          for f in features:
              self.gen.logMsg('diag', 'PASS 1: Tagging required and removed features for',
                              f.name)
              self.fillFeatureDictionary(f.elem, f.name, self.genOpts.apiname, self.genOpts.profile)
              self.requireAndRemoveFeatures(f.elem, f.name, self.genOpts.apiname, self.genOpts.profile)
              self.assignAdditionalValidity(f.elem, self.genOpts.apiname, self.genOpts.profile)
  
          # Pass 2: loop over specified API versions and extensions printing
          #   declarations for required things which haven't already been
          #   generated.
          self.gen.logMsg('diag', 'PASS 2: GENERATE INTERFACES FOR FEATURES')
          self.gen.beginFile(self.genOpts)
          for f in features:
              self.gen.logMsg('diag', 'PASS 2: Generating interface for',
                              f.name)
              emit = self.emitFeatures = f.emit
              if not emit:
                  self.gen.logMsg('diag', 'PASS 2: NOT declaring feature',
                                  f.elem.get('name'), 'because it is not tagged for emission')
              # Generate the interface (or just tag its elements as having been
              # emitted, if they haven't been).
              self.gen.beginFeature(f.elem, emit)
              self.generateRequiredInterface(f.elem)
              self.gen.endFeature()
          # Generate spirv elements
          for s in spirvexts:
              self.generateSpirv(s, self.spirvextdict)
          for s in spirvcaps:
              self.generateSpirv(s, self.spirvcapdict)
          self.gen.endFile()
function_tokens: def apiGen ( self ) : self . gen . logMsg ( 'diag' , '*******************************************' ) self . gen . logMsg ( 'diag' , '  Registry.apiGen file:' , self . genOpts . filename , 'api:' , self . genOpts . apiname , 'profile:' , self . genOpts . profile ) self . gen . logMsg ( 'diag' , '*******************************************' ) # Reset required/declared flags for all features self . apiReset ( ) # Compile regexps used to select versions & extensions regVersions = re . compile ( self . genOpts . versions ) regEmitVersions = re . compile ( self . genOpts . emitversions ) regAddExtensions = re . compile ( self . genOpts . addExtensions ) regRemoveExtensions = re . compile ( self . genOpts . removeExtensions ) regEmitExtensions = re . compile ( self . genOpts . emitExtensions ) regEmitSpirv = re . compile ( self . genOpts . emitSpirv ) # Get all matching API feature names & add to list of FeatureInfo # Note we used to select on feature version attributes, not names. features = [ ] apiMatch = False for key in self . apidict : fi = self . apidict [ key ] api = fi . elem . get ( 'api' ) if apiNameMatch ( self . genOpts . apiname , api ) : apiMatch = True if regVersions . match ( fi . name ) : # Matches API & version #s being generated. Mark for # emission and add to the features[] list . # @@ Could use 'declared' instead of 'emit'? fi . emit = ( regEmitVersions . match ( fi . name ) is not None ) features . append ( fi ) if not fi . emit : self . gen . logMsg ( 'diag' , 'NOT tagging feature api =' , api , 'name =' , fi . name , 'version =' , fi . version , 'for emission (does not match emitversions pattern)' ) else : self . gen . logMsg ( 'diag' , 'Including feature api =' , api , 'name =' , fi . name , 'version =' , fi . version , 'for emission (matches emitversions pattern)' ) else : self . gen . logMsg ( 'diag' , 'NOT including feature api =' , api , 'name =' , fi . name , 'version =' , fi . version , '(does not match requested versions)' ) else : self . gen . logMsg ( 'diag' , 'NOT including feature api =' , api , 'name =' , fi . name , '(does not match requested API)' ) if not apiMatch : self . gen . logMsg ( 'warn' , 'No matching API versions found!' ) # Get all matching extensions, in order by their extension number, # and add to the list of features. # Start with extensions tagged with 'api' pattern matching the API # being generated. Add extensions matching the pattern specified in # regExtensions, then remove extensions matching the pattern # specified in regRemoveExtensions for ( extName , ei ) in sorted ( self . extdict . items ( ) , key = lambda x : x [ 1 ] . number if x [ 1 ] . number is not None else '0' ) : extName = ei . name include = False # Include extension if defaultExtensions is not None and is # exactly matched by the 'supported' attribute. if apiNameMatch ( self . genOpts . defaultExtensions , ei . elem . get ( 'supported' ) ) : self . gen . logMsg ( 'diag' , 'Including extension' , extName , "(defaultExtensions matches the 'supported' attribute)" ) include = True # Include additional extensions if the extension name matches # the regexp specified in the generator options. This allows # forcing extensions into an interface even if they're not # tagged appropriately in the registry. # However we still respect the 'supported' attribute. if regAddExtensions . match ( extName ) is not None : if not apiNameMatch ( self . genOpts . apiname , ei . elem . get ( 'supported' ) ) : self . gen . logMsg ( 'diag' , 'NOT including extension' , extName , '(matches explicitly requested, but does not match the \'supported\' attribute)' ) include = False else : self . gen . logMsg ( 'diag' , 'Including extension' , extName , '(matches explicitly requested extensions to add)' ) include = True # Remove extensions if the name matches the regexp specified # in generator options. This allows forcing removal of # extensions from an interface even if they're tagged that # way in the registry. if regRemoveExtensions . match ( extName ) is not None : self . gen . logMsg ( 'diag' , 'Removing extension' , extName , '(matches explicitly requested extensions to remove)' ) include = False # If the extension is to be included, add it to the # extension features list. if include : ei . emit = ( regEmitExtensions . match ( extName ) is not None ) features . append ( ei ) if not ei . emit : self . gen . logMsg ( 'diag' , 'NOT tagging extension' , extName , 'for emission (does not match emitextensions pattern)' ) # Hack - can be removed when validity generator goes away # (Jon) I'm not sure what this does, or if it should respect # the ei.emit flag above. self . requiredextensions . append ( extName ) else : self . gen . logMsg ( 'diag' , 'NOT including extension' , extName , '(does not match api attribute or explicitly requested extensions)' ) # Add all spirv elements to list # generators decide to emit them all or not # Currently no filtering as no client of these elements needs filtering spirvexts = [ ] for key in self . spirvextdict : si = self . spirvextdict [ key ] si . emit = ( regEmitSpirv . match ( key ) is not None ) spirvexts . append ( si ) spirvcaps = [ ] for key in self . spirvcapdict : si = self . spirvcapdict [ key ] si . emit = ( regEmitSpirv . match ( key ) is not None ) spirvcaps . append ( si ) # Sort the features list, if a sort procedure is defined if self . genOpts . sortProcedure : self . genOpts . sortProcedure ( features ) # print('sortProcedure ->', [f.name for f in features]) # Pass 1: loop over requested API versions and extensions tagging #   types/commands/features as required (in an <require> block) or no #   longer required (in an <remove> block). It is possible to remove #   a feature in one version and restore it later by requiring it in #   a later version. # If a profile other than 'None' is being generated, it must #   match the profile attribute (if any) of the <require> and #   <remove> tags. self . gen . logMsg ( 'diag' , 'PASS 1: TAG FEATURES' ) for f in features : self . gen . logMsg ( 'diag' , 'PASS 1: Tagging required and removed features for' , f . name ) self . fillFeatureDictionary ( f . elem , f . name , self . genOpts . apiname , self . genOpts . profile ) self . requireAndRemoveFeatures ( f . elem , f . name , self . genOpts . apiname , self . genOpts . profile ) self . assignAdditionalValidity ( f . elem , self . genOpts . apiname , self . genOpts . profile ) # Pass 2: loop over specified API versions and extensions printing #   declarations for required things which haven't already been #   generated. self . gen . logMsg ( 'diag' , 'PASS 2: GENERATE INTERFACES FOR FEATURES' ) self . gen . beginFile ( self . genOpts ) for f in features : self . gen . logMsg ( 'diag' , 'PASS 2: Generating interface for' , f . name ) emit = self . emitFeatures = f . emit if not emit : self . gen . logMsg ( 'diag' , 'PASS 2: NOT declaring feature' , f . elem . get ( 'name' ) , 'because it is not tagged for emission' ) # Generate the interface (or just tag its elements as having been # emitted, if they haven't been). self . gen . beginFeature ( f . elem , emit ) self . generateRequiredInterface ( f . elem ) self . gen . endFeature ( ) # Generate spirv elements for s in spirvexts : self . generateSpirv ( s , self . spirvextdict ) for s in spirvcaps : self . generateSpirv ( s , self . spirvcapdict ) self . gen . endFile ( )