parameters: (functions, extension_headers, extra_extensions)
return_statement: return used_extension_functions
docstring: Determine which functions belong to extensions.
  
    Args:
      functions: List of (return type, function names, arguments).
      extension_headers: List of header file names.
    Returns:
      List of (extension name, [function name alternatives]) sorted with least
      preferred extensions first.
docstring_summary: Determine which functions belong to extensions.
docstring_tokens: Determine which functions belong to extensions .
function: def GetUsedExtensionFunctions(functions, extension_headers, extra_extensions):
    """Determine which functions belong to extensions.
  
    Args:
      functions: List of (return type, function names, arguments).
      extension_headers: List of header file names.
    Returns:
      List of (extension name, [function name alternatives]) sorted with least
      preferred extensions first.
    """
    # Parse known extensions.
    extensions = GetExtensionFunctions(extension_headers)
    functions_to_extensions = GetFunctionToExtensionMap(extensions)
  
    # Collect all used extension functions.
    used_extension_functions = collections.defaultdict(lambda: [])
    for func in functions:
      for name in func['names']:
        # Make sure we know about all extension functions.
        if (LooksLikeExtensionFunction(name) and
            not name in functions_to_extensions):
          raise RuntimeError('%s looks like an extension function but does not '
              'belong to any of the known extensions.' % name)
        if name in functions_to_extensions:
          extensions = functions_to_extensions[name][:]
          if 'other_extensions' in func:
            extensions.extend(func['other_extensions'])
          for extension in extensions:
            used_extension_functions[extension].append((func['names'][0], name))
  
    # Add extensions that do not have any functions.
    used_extension_functions.update(dict(
        [(e, []) for e in extra_extensions if e not in used_extension_functions]))
  
    def ExtensionSortKey(name):
      # Prefer ratified extensions and EXTs.
      preferences = ['_ARB_', '_OES_', '_EXT_', '']
      for i, category in enumerate(preferences):
        if category in name:
          return -i
    used_extension_functions = sorted(used_extension_functions.items(),
        key = lambda item: ExtensionSortKey(item[0]))
    return used_extension_functions
function_tokens: def GetUsedExtensionFunctions ( functions , extension_headers , extra_extensions ) : # Parse known extensions. extensions = GetExtensionFunctions ( extension_headers ) functions_to_extensions = GetFunctionToExtensionMap ( extensions ) # Collect all used extension functions. used_extension_functions = collections . defaultdict ( lambda : [ ] ) for func in functions : for name in func [ 'names' ] : # Make sure we know about all extension functions. if ( LooksLikeExtensionFunction ( name ) and not name in functions_to_extensions ) : raise RuntimeError ( '%s looks like an extension function but does not ' 'belong to any of the known extensions.' % name ) if name in functions_to_extensions : extensions = functions_to_extensions [ name ] [ : ] if 'other_extensions' in func : extensions . extend ( func [ 'other_extensions' ] ) for extension in extensions : used_extension_functions [ extension ] . append ( ( func [ 'names' ] [ 0 ] , name ) ) # Add extensions that do not have any functions. used_extension_functions . update ( dict ( [ ( e , [ ] ) for e in extra_extensions if e not in used_extension_functions ] ) ) def ExtensionSortKey ( name ) : # Prefer ratified extensions and EXTs. preferences = [ '_ARB_' , '_OES_' , '_EXT_' , '' ] for i , category in enumerate ( preferences ) : if category in name : return - i used_extension_functions = sorted ( used_extension_functions . items ( ) , key = lambda item : ExtensionSortKey ( item [ 0 ] ) ) return used_extension_functions