gpu/command_buffer/build_cmd_buffer_lib.py
def WriteServiceUtilsImplementation(self, filename):
    """Writes the gles2 auto generated utility implementation."""
    with CHeaderWriter(filename, self.year) as f:
      names = sorted(self.named_type_info.keys())
      for name in names:
        named_type = NamedType(self.named_type_info[name])
        class_name = ValidatorClassName(name)
        if not named_type.CreateValidator():
          continue
        if named_type.IsComplete():
          if named_type.HasES3Values():
            f.write("""Validators::%(class_name)s::%(class_name)s()
                         : is_es3_(false) {}""" % { 'class_name': class_name })

          f.write("""bool Validators::%(class_name)s::IsValid(
                         const %(type)s value) const {
                       switch(value) {\n""" % {
            'class_name': class_name,
            'type': named_type.GetType()
          })
          if named_type.GetValidValues():
            for value in named_type.GetValidValues():
                f.write("case %s:\n" % value)
            f.write("return true;\n")
          if named_type.GetValidValuesES3():
            for value in named_type.GetValidValuesES3():
                f.write("case %s:\n" % value)
            f.write("return is_es3_;\n")
          if named_type.GetDeprecatedValuesES3():
            for value in named_type.GetDeprecatedValuesES3():
                f.write("case %s:\n" % value)
            f.write("return !is_es3_;\n")
          f.write("}\nreturn false;\n}\n")
          f.write("\n")
        else:
          if named_type.GetValidValues():
            f.write("static const %s valid_%s_table[] = {\n" %
                       (named_type.GetType(), ToUnderscore(name)))
            for value in named_type.GetValidValues():
              f.write("  %s,\n" % value)
            f.write("};\n")
            f.write("\n")
          if named_type.GetValidValuesES3():
            f.write("static const %s valid_%s_table_es3[] = {\n" %
                       (named_type.GetType(), ToUnderscore(name)))
            for value in named_type.GetValidValuesES3():
              f.write("  %s,\n" % value)
            f.write("};\n")
            f.write("\n")
          if named_type.GetDeprecatedValuesES3():
            f.write("static const %s deprecated_%s_table_es3[] = {\n" %
                       (named_type.GetType(), ToUnderscore(name)))
            for value in named_type.GetDeprecatedValuesES3():
              f.write("  %s,\n" % value)
            f.write("};\n")
          f.write("\n")
      f.write("Validators::Validators()")
      pre = '    : '
      for name in names:
        named_type = NamedType(self.named_type_info[name])
        if not named_type.CreateValidator() or named_type.IsComplete():
          continue
        if named_type.GetValidValues():
          code = """%(pre)s%(name)s(
            valid_%(name)s_table, base::size(valid_%(name)s_table))"""
        else:
          code = "%(pre)s%(name)s()"
        f.write(code % {
          'name': ToUnderscore(name),
          'pre': pre,
        })
        pre = ',\n    '
      f.write(" {\n");
      f.write("}\n\n");

      if _prefix == 'GLES2':
        f.write("void Validators::UpdateValuesES3() {\n")
        for name in names:
          named_type = NamedType(self.named_type_info[name])
          if not named_type.IsConstant() and named_type.IsComplete():
            if named_type.HasES3Values():
              f.write("  %(name)s.SetIsES3(true);" % {
                'name': ToUnderscore(name),
              })
            continue
          if named_type.GetDeprecatedValuesES3():
            code = """  %(name)s.RemoveValues(
      deprecated_%(name)s_table_es3, base::size(deprecated_%(name)s_table_es3));
"""
            f.write(code % {
              'name': ToUnderscore(name),
            })
          if named_type.GetValidValuesES3():
            code = """  %(name)s.AddValues(
      valid_%(name)s_table_es3, base::size(valid_%(name)s_table_es3));
"""
            f.write(code % {
              'name': ToUnderscore(name),
            })
        f.write("}\n\n");

        f.write("void Validators::UpdateETCCompressedTextureFormats() {\n")
        for name in ['CompressedTextureFormat', 'TextureInternalFormatStorage']:
          for fmt in _ETC_COMPRESSED_TEXTURE_FORMATS:
            code = """  %(name)s.AddValue(%(format)s);
"""
            f.write(code % {
              'name': ToUnderscore(name),
              'format': fmt,
            })
        f.write("}\n\n");
    self.generated_cpp_filenames.append(filename)
Writes the gles2 auto generated utility implementation.
Writes the gles2 auto generated utility implementation.
Writes the gles2 auto generated utility implementation .
def WriteServiceUtilsImplementation(self, filename):
    with CHeaderWriter(filename, self.year) as f:
      names = sorted(self.named_type_info.keys())
      for name in names:
        named_type = NamedType(self.named_type_info[name])
        class_name = ValidatorClassName(name)
        if not named_type.CreateValidator():
          continue
        if named_type.IsComplete():
          if named_type.HasES3Values():
            f.write("""Validators::%(class_name)s::%(class_name)s()
                         : is_es3_(false) {}""" % { 'class_name': class_name })
          f.write("""bool Validators::%(class_name)s::IsValid(
                         const %(type)s value) const {
                       switch(value) {\n""" % {
            'class_name': class_name,
            'type': named_type.GetType()
          })
          if named_type.GetValidValues():
            for value in named_type.GetValidValues():
                f.write("case %s:\n" % value)
            f.write("return true;\n")
          if named_type.GetValidValuesES3():
            for value in named_type.GetValidValuesES3():
                f.write("case %s:\n" % value)
            f.write("return is_es3_;\n")
          if named_type.GetDeprecatedValuesES3():
            for value in named_type.GetDeprecatedValuesES3():
                f.write("case %s:\n" % value)
            f.write("return !is_es3_;\n")
          f.write("}\nreturn false;\n}\n")
          f.write("\n")
        else:
          if named_type.GetValidValues():
            f.write("static const %s valid_%s_table[] = {\n" %
                       (named_type.GetType(), ToUnderscore(name)))
            for value in named_type.GetValidValues():
              f.write("  %s,\n" % value)
            f.write("};\n")
            f.write("\n")
          if named_type.GetValidValuesES3():
            f.write("static const %s valid_%s_table_es3[] = {\n" %
                       (named_type.GetType(), ToUnderscore(name)))
            for value in named_type.GetValidValuesES3():
              f.write("  %s,\n" % value)
            f.write("};\n")
            f.write("\n")
          if named_type.GetDeprecatedValuesES3():
            f.write("static const %s deprecated_%s_table_es3[] = {\n" %
                       (named_type.GetType(), ToUnderscore(name)))
            for value in named_type.GetDeprecatedValuesES3():
              f.write("  %s,\n" % value)
            f.write("};\n")
          f.write("\n")
      f.write("Validators::Validators()")
      pre = '    : '
      for name in names:
        named_type = NamedType(self.named_type_info[name])
        if not named_type.CreateValidator() or named_type.IsComplete():
          continue
        if named_type.GetValidValues():
          code = """%(pre)s%(name)s(
            valid_%(name)s_table, base::size(valid_%(name)s_table))"""
        else:
          code = "%(pre)s%(name)s()"
        f.write(code % {
          'name': ToUnderscore(name),
          'pre': pre,
        })
        pre = ',\n    '
      f.write(" {\n");
      f.write("}\n\n");
      if _prefix == 'GLES2':
        f.write("void Validators::UpdateValuesES3() {\n")
        for name in names:
          named_type = NamedType(self.named_type_info[name])
          if not named_type.IsConstant() and named_type.IsComplete():
            if named_type.HasES3Values():
              f.write("  %(name)s.SetIsES3(true);" % {
                'name': ToUnderscore(name),
              })
            continue
          if named_type.GetDeprecatedValuesES3():
            code = """  %(name)s.RemoveValues(
      deprecated_%(name)s_table_es3, base::size(deprecated_%(name)s_table_es3));
"""
            f.write(code % {
              'name': ToUnderscore(name),
            })
          if named_type.GetValidValuesES3():
            code = """  %(name)s.AddValues(
      valid_%(name)s_table_es3, base::size(valid_%(name)s_table_es3));
"""
            f.write(code % {
              'name': ToUnderscore(name),
            })
        f.write("}\n\n");
        f.write("void Validators::UpdateETCCompressedTextureFormats() {\n")
        for name in ['CompressedTextureFormat', 'TextureInternalFormatStorage']:
          for fmt in _ETC_COMPRESSED_TEXTURE_FORMATS:
            code = """  %(name)s.AddValue(%(format)s);
"""
            f.write(code % {
              'name': ToUnderscore(name),
              'format': fmt,
            })
        f.write("}\n\n");
    self.generated_cpp_filenames.append(filename)
def WriteServiceUtilsImplementation ( self , filename ) : with CHeaderWriter ( filename , self . year ) as f : names = sorted ( self . named_type_info . keys ( ) ) for name in names : named_type = NamedType ( self . named_type_info [ name ] ) class_name = ValidatorClassName ( name ) if not named_type . CreateValidator ( ) : continue if named_type . IsComplete ( ) : if named_type . HasES3Values ( ) : f . write ( """Validators::%(class_name)s::%(class_name)s()
                         : is_es3_(false) {}""" % { 'class_name' : class_name } ) f . write ( """bool Validators::%(class_name)s::IsValid(
                         const %(type)s value) const {
                       switch(value) {\n""" % { 'class_name' : class_name , 'type' : named_type . GetType ( ) } ) if named_type . GetValidValues ( ) : for value in named_type . GetValidValues ( ) : f . write ( "case %s:\n" % value ) f . write ( "return true;\n" ) if named_type . GetValidValuesES3 ( ) : for value in named_type . GetValidValuesES3 ( ) : f . write ( "case %s:\n" % value ) f . write ( "return is_es3_;\n" ) if named_type . GetDeprecatedValuesES3 ( ) : for value in named_type . GetDeprecatedValuesES3 ( ) : f . write ( "case %s:\n" % value ) f . write ( "return !is_es3_;\n" ) f . write ( "}\nreturn false;\n}\n" ) f . write ( "\n" ) else : if named_type . GetValidValues ( ) : f . write ( "static const %s valid_%s_table[] = {\n" % ( named_type . GetType ( ) , ToUnderscore ( name ) ) ) for value in named_type . GetValidValues ( ) : f . write ( "  %s,\n" % value ) f . write ( "};\n" ) f . write ( "\n" ) if named_type . GetValidValuesES3 ( ) : f . write ( "static const %s valid_%s_table_es3[] = {\n" % ( named_type . GetType ( ) , ToUnderscore ( name ) ) ) for value in named_type . GetValidValuesES3 ( ) : f . write ( "  %s,\n" % value ) f . write ( "};\n" ) f . write ( "\n" ) if named_type . GetDeprecatedValuesES3 ( ) : f . write ( "static const %s deprecated_%s_table_es3[] = {\n" % ( named_type . GetType ( ) , ToUnderscore ( name ) ) ) for value in named_type . GetDeprecatedValuesES3 ( ) : f . write ( "  %s,\n" % value ) f . write ( "};\n" ) f . write ( "\n" ) f . write ( "Validators::Validators()" ) pre = '    : ' for name in names : named_type = NamedType ( self . named_type_info [ name ] ) if not named_type . CreateValidator ( ) or named_type . IsComplete ( ) : continue if named_type . GetValidValues ( ) : code = """%(pre)s%(name)s(
            valid_%(name)s_table, base::size(valid_%(name)s_table))""" else : code = "%(pre)s%(name)s()" f . write ( code % { 'name' : ToUnderscore ( name ) , 'pre' : pre , } ) pre = ',\n    ' f . write ( " {\n" ) ; f . write ( "}\n\n" ) ; if _prefix == 'GLES2' : f . write ( "void Validators::UpdateValuesES3() {\n" ) for name in names : named_type = NamedType ( self . named_type_info [ name ] ) if not named_type . IsConstant ( ) and named_type . IsComplete ( ) : if named_type . HasES3Values ( ) : f . write ( "  %(name)s.SetIsES3(true);" % { 'name' : ToUnderscore ( name ) , } ) continue if named_type . GetDeprecatedValuesES3 ( ) : code = """  %(name)s.RemoveValues(
      deprecated_%(name)s_table_es3, base::size(deprecated_%(name)s_table_es3));
""" f . write ( code % { 'name' : ToUnderscore ( name ) , } ) if named_type . GetValidValuesES3 ( ) : code = """  %(name)s.AddValues(
      valid_%(name)s_table_es3, base::size(valid_%(name)s_table_es3));
""" f . write ( code % { 'name' : ToUnderscore ( name ) , } ) f . write ( "}\n\n" ) ; f . write ( "void Validators::UpdateETCCompressedTextureFormats() {\n" ) for name in [ 'CompressedTextureFormat' , 'TextureInternalFormatStorage' ] : for fmt in _ETC_COMPRESSED_TEXTURE_FORMATS : code = """  %(name)s.AddValue(%(format)s);
""" f . write ( code % { 'name' : ToUnderscore ( name ) , 'format' : fmt , } ) f . write ( "}\n\n" ) ; self . generated_cpp_filenames . append ( filename )
Writes the gles2 auto generated utility implementation.
Writes the gles2 auto generated utility implementation .
"""Writes the gles2 auto generated utility implementation."""
self
filename