original_docstring: Writes the gles2 common utility header.
docstring: Writes the gles2 common utility header.
docstring_tokens: Writes the gles2 common utility header .
code: def WriteCommonUtilsImpl(self, filename):
      """Writes the gles2 common utility header."""
      enum_re = re.compile(r'\#define\s+(GL_[a-zA-Z0-9_]+)\s+([0-9A-Fa-fx]+)')
      dict = {}
      for fname in ['third_party/khronos/GLES2/gl2.h',
                    'third_party/khronos/GLES2/gl2ext.h',
                    'gpu/GLES2/gl2chromium.h',
                    'gpu/GLES2/gl2extchromium.h']:
        lines = open(fname).readlines()
        for line in lines:
          m = enum_re.match(line)
          if m:
            name = m.group(1)
            value = m.group(2)
            if len(value) <= 10:
              if not value in dict:
                dict[value] = name
              # check our own _CHROMIUM macro conflicts with khronos GL headers.
              elif dict[value] != name and (name.endswith('_CHROMIUM') or
                  dict[value].endswith('_CHROMIUM')):
                self.Error("code collision: %s and %s have the same code %s" %
                           (dict[value], name, value))
  
      file = CHeaderWriter(filename)
      file.Write("static const GLES2Util::EnumToString "
                 "enum_to_string_table[] = {\n")
      for value in dict:
        file.Write('  { %s, "%s", },\n' % (value, dict[value]))
      file.Write("""};
  
  const GLES2Util::EnumToString* const GLES2Util::enum_to_string_table_ =
      enum_to_string_table;
  const size_t GLES2Util::enum_to_string_table_len_ =
      sizeof(enum_to_string_table) / sizeof(enum_to_string_table[0]);
  
  """)
  
      enums = sorted(_NAMED_TYPE_INFO.keys())
      for enum in enums:
        if _NAMED_TYPE_INFO[enum]['type'] == 'GLenum':
          file.Write("std::string GLES2Util::GetString%s(uint32_t value) {\n" %
                     enum)
          if len(_NAMED_TYPE_INFO[enum]['valid']) > 0:
            file.Write("  static const EnumToString string_table[] = {\n")
            for value in _NAMED_TYPE_INFO[enum]['valid']:
              file.Write('    { %s, "%s" },\n' % (value, value))
            file.Write("""  };
    return GLES2Util::GetQualifiedEnumString(
        string_table, arraysize(string_table), value);
  }
  
  """)
          else:
            file.Write("""  return GLES2Util::GetQualifiedEnumString(
        NULL, 0, value);
  }
  
  """)
      file.Close()
      self.generated_cpp_filenames.append(file.filename)
code_tokens: def WriteCommonUtilsImpl ( self , filename ) : enum_re = re . compile ( r'\#define\s+(GL_[a-zA-Z0-9_]+)\s+([0-9A-Fa-fx]+)' ) dict = { } for fname in [ 'third_party/khronos/GLES2/gl2.h' , 'third_party/khronos/GLES2/gl2ext.h' , 'gpu/GLES2/gl2chromium.h' , 'gpu/GLES2/gl2extchromium.h' ] : lines = open ( fname ) . readlines ( ) for line in lines : m = enum_re . match ( line ) if m : name = m . group ( 1 ) value = m . group ( 2 ) if len ( value ) <= 10 : if not value in dict : dict [ value ] = name elif dict [ value ] != name and ( name . endswith ( '_CHROMIUM' ) or dict [ value ] . endswith ( '_CHROMIUM' ) ) : self . Error ( "code collision: %s and %s have the same code %s" % ( dict [ value ] , name , value ) ) file = CHeaderWriter ( filename ) file . Write ( "static const GLES2Util::EnumToString " "enum_to_string_table[] = {\n" ) for value in dict : file . Write ( '  { %s, "%s", },\n' % ( value , dict [ value ] ) ) file . Write ( """};
  
  const GLES2Util::EnumToString* const GLES2Util::enum_to_string_table_ =
      enum_to_string_table;
  const size_t GLES2Util::enum_to_string_table_len_ =
      sizeof(enum_to_string_table) / sizeof(enum_to_string_table[0]);
  
  """ ) enums = sorted ( _NAMED_TYPE_INFO . keys ( ) ) for enum in enums : if _NAMED_TYPE_INFO [ enum ] [ 'type' ] == 'GLenum' : file . Write ( "std::string GLES2Util::GetString%s(uint32_t value) {\n" % enum ) if len ( _NAMED_TYPE_INFO [ enum ] [ 'valid' ] ) > 0 : file . Write ( "  static const EnumToString string_table[] = {\n" ) for value in _NAMED_TYPE_INFO [ enum ] [ 'valid' ] : file . Write ( '    { %s, "%s" },\n' % ( value , value ) ) file . Write ( """  };
    return GLES2Util::GetQualifiedEnumString(
        string_table, arraysize(string_table), value);
  }
  
  """ ) else : file . Write ( """  return GLES2Util::GetQualifiedEnumString(
        NULL, 0, value);
  }
  
  """ ) file . Close ( ) self . generated_cpp_filenames . append ( file . filename )
short_docstring: Writes the gles2 common utility header.
short_docstring_tokens: Writes the gles2 common utility header .
comment: """Writes the gles2 common utility header."""$SEP$# check our own _CHROMIUM macro conflicts with khronos GL headers.