original_docstring: This is the main function.
docstring: This is the main function.
docstring_tokens: This is the main function .
code: def main(argv):
    """This is the main function."""
    parser = OptionParser()
    parser.add_option(
        "--output-dir",
        help="base directory for resulting files, under chrome/src. default is "
        "empty. Use this if you want the result stored under gen.")
    parser.add_option(
        "-v", "--verbose", action="store_true",
        help="prints more output.")
  
    (options, args) = parser.parse_args(args=argv)
  
    # Add in states and capabilites to GLState
    gl_state_valid = _NAMED_TYPE_INFO['GLState']['valid']
    for state_name in sorted(_STATES.keys()):
      state = _STATES[state_name]
      if 'extension_flag' in state:
        continue
      if 'enum' in state:
        if not state['enum'] in gl_state_valid:
          gl_state_valid.append(state['enum'])
      else:
        for item in state['states']:
          if 'extension_flag' in item:
            continue
          if not item['enum'] in gl_state_valid:
            gl_state_valid.append(item['enum'])
    for capability in _CAPABILITY_FLAGS:
      valid_value = "GL_%s" % capability['name'].upper()
      if not valid_value in gl_state_valid:
        gl_state_valid.append(valid_value)
  
    # This script lives under gpu/command_buffer, cd to base directory.
    os.chdir(os.path.dirname(__file__) + "/../..")
    base_dir = os.getcwd()
    gen = GLGenerator(options.verbose)
    gen.ParseGLH("gpu/command_buffer/cmd_buffer_functions.txt")
  
    # Support generating files under gen/
    if options.output_dir != None:
      os.chdir(options.output_dir)
  
    gen.WritePepperGLES2Interface("ppapi/api/ppb_opengles2.idl", False)
    gen.WritePepperGLES2Interface("ppapi/api/dev/ppb_opengles2ext_dev.idl", True)
    gen.WriteGLES2ToPPAPIBridge("ppapi/lib/gl/gles2/gles2.c")
    gen.WritePepperGLES2Implementation(
        "ppapi/shared_impl/ppb_opengles2_shared.cc")
    os.chdir(base_dir)
    gen.WriteCommandIds("gpu/command_buffer/common/gles2_cmd_ids_autogen.h")
    gen.WriteFormat("gpu/command_buffer/common/gles2_cmd_format_autogen.h")
    gen.WriteFormatTest(
      "gpu/command_buffer/common/gles2_cmd_format_test_autogen.h")
    gen.WriteGLES2InterfaceHeader(
      "gpu/command_buffer/client/gles2_interface_autogen.h")
    gen.WriteGLES2InterfaceStub(
      "gpu/command_buffer/client/gles2_interface_stub_autogen.h")
    gen.WriteGLES2InterfaceStubImpl(
        "gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h")
    gen.WriteGLES2ImplementationHeader(
      "gpu/command_buffer/client/gles2_implementation_autogen.h")
    gen.WriteGLES2Implementation(
      "gpu/command_buffer/client/gles2_implementation_impl_autogen.h")
    gen.WriteGLES2ImplementationUnitTests(
        "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h")
    gen.WriteGLES2TraceImplementationHeader(
        "gpu/command_buffer/client/gles2_trace_implementation_autogen.h")
    gen.WriteGLES2TraceImplementation(
        "gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h")
    gen.WriteGLES2CLibImplementation(
      "gpu/command_buffer/client/gles2_c_lib_autogen.h")
    gen.WriteCmdHelperHeader(
      "gpu/command_buffer/client/gles2_cmd_helper_autogen.h")
    gen.WriteServiceImplementation(
      "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h")
    gen.WriteServiceContextStateHeader(
      "gpu/command_buffer/service/context_state_autogen.h")
    gen.WriteServiceContextStateImpl(
      "gpu/command_buffer/service/context_state_impl_autogen.h")
    gen.WriteClientContextStateHeader(
      "gpu/command_buffer/client/client_context_state_autogen.h")
    gen.WriteClientContextStateImpl(
        "gpu/command_buffer/client/client_context_state_impl_autogen.h")
    gen.WriteServiceUnitTests(
      "gpu/command_buffer/service/gles2_cmd_decoder_unittest_%d_autogen.h")
    gen.WriteServiceUnitTestsForExtensions(
      "gpu/command_buffer/service/"
      "gles2_cmd_decoder_unittest_extensions_autogen.h")
    gen.WriteServiceUtilsHeader(
      "gpu/command_buffer/service/gles2_cmd_validation_autogen.h")
    gen.WriteServiceUtilsImplementation(
      "gpu/command_buffer/service/"
      "gles2_cmd_validation_implementation_autogen.h")
    gen.WriteCommonUtilsHeader(
      "gpu/command_buffer/common/gles2_cmd_utils_autogen.h")
    gen.WriteCommonUtilsImpl(
      "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h")
    gen.WriteGLES2Header("gpu/GLES2/gl2chromium_autogen.h")
    mojo_gles2_prefix = "mojo/public/c/gles2/gles2_call_visitor"
    gen.WriteMojoGLCallVisitor(mojo_gles2_prefix + "_autogen.h")
    gen.WriteMojoGLCallVisitorForExtension(
        mojo_gles2_prefix + "_chromium_texture_mailbox_autogen.h",
        "CHROMIUM_texture_mailbox")
    gen.WriteMojoGLCallVisitorForExtension(
        mojo_gles2_prefix + "_chromium_sync_point_autogen.h",
        "CHROMIUM_sync_point")
  
    Format(gen.generated_cpp_filenames)
  
    if gen.errors > 0:
      print "%d errors" % gen.errors
      return 1
    return 0
code_tokens: def main ( argv ) : parser = OptionParser ( ) parser . add_option ( "--output-dir" , help = "base directory for resulting files, under chrome/src. default is " "empty. Use this if you want the result stored under gen." ) parser . add_option ( "-v" , "--verbose" , action = "store_true" , help = "prints more output." ) ( options , args ) = parser . parse_args ( args = argv ) gl_state_valid = _NAMED_TYPE_INFO [ 'GLState' ] [ 'valid' ] for state_name in sorted ( _STATES . keys ( ) ) : state = _STATES [ state_name ] if 'extension_flag' in state : continue if 'enum' in state : if not state [ 'enum' ] in gl_state_valid : gl_state_valid . append ( state [ 'enum' ] ) else : for item in state [ 'states' ] : if 'extension_flag' in item : continue if not item [ 'enum' ] in gl_state_valid : gl_state_valid . append ( item [ 'enum' ] ) for capability in _CAPABILITY_FLAGS : valid_value = "GL_%s" % capability [ 'name' ] . upper ( ) if not valid_value in gl_state_valid : gl_state_valid . append ( valid_value ) os . chdir ( os . path . dirname ( __file__ ) + "/../.." ) base_dir = os . getcwd ( ) gen = GLGenerator ( options . verbose ) gen . ParseGLH ( "gpu/command_buffer/cmd_buffer_functions.txt" ) if options . output_dir != None : os . chdir ( options . output_dir ) gen . WritePepperGLES2Interface ( "ppapi/api/ppb_opengles2.idl" , False ) gen . WritePepperGLES2Interface ( "ppapi/api/dev/ppb_opengles2ext_dev.idl" , True ) gen . WriteGLES2ToPPAPIBridge ( "ppapi/lib/gl/gles2/gles2.c" ) gen . WritePepperGLES2Implementation ( "ppapi/shared_impl/ppb_opengles2_shared.cc" ) os . chdir ( base_dir ) gen . WriteCommandIds ( "gpu/command_buffer/common/gles2_cmd_ids_autogen.h" ) gen . WriteFormat ( "gpu/command_buffer/common/gles2_cmd_format_autogen.h" ) gen . WriteFormatTest ( "gpu/command_buffer/common/gles2_cmd_format_test_autogen.h" ) gen . WriteGLES2InterfaceHeader ( "gpu/command_buffer/client/gles2_interface_autogen.h" ) gen . WriteGLES2InterfaceStub ( "gpu/command_buffer/client/gles2_interface_stub_autogen.h" ) gen . WriteGLES2InterfaceStubImpl ( "gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h" ) gen . WriteGLES2ImplementationHeader ( "gpu/command_buffer/client/gles2_implementation_autogen.h" ) gen . WriteGLES2Implementation ( "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" ) gen . WriteGLES2ImplementationUnitTests ( "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" ) gen . WriteGLES2TraceImplementationHeader ( "gpu/command_buffer/client/gles2_trace_implementation_autogen.h" ) gen . WriteGLES2TraceImplementation ( "gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h" ) gen . WriteGLES2CLibImplementation ( "gpu/command_buffer/client/gles2_c_lib_autogen.h" ) gen . WriteCmdHelperHeader ( "gpu/command_buffer/client/gles2_cmd_helper_autogen.h" ) gen . WriteServiceImplementation ( "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" ) gen . WriteServiceContextStateHeader ( "gpu/command_buffer/service/context_state_autogen.h" ) gen . WriteServiceContextStateImpl ( "gpu/command_buffer/service/context_state_impl_autogen.h" ) gen . WriteClientContextStateHeader ( "gpu/command_buffer/client/client_context_state_autogen.h" ) gen . WriteClientContextStateImpl ( "gpu/command_buffer/client/client_context_state_impl_autogen.h" ) gen . WriteServiceUnitTests ( "gpu/command_buffer/service/gles2_cmd_decoder_unittest_%d_autogen.h" ) gen . WriteServiceUnitTestsForExtensions ( "gpu/command_buffer/service/" "gles2_cmd_decoder_unittest_extensions_autogen.h" ) gen . WriteServiceUtilsHeader ( "gpu/command_buffer/service/gles2_cmd_validation_autogen.h" ) gen . WriteServiceUtilsImplementation ( "gpu/command_buffer/service/" "gles2_cmd_validation_implementation_autogen.h" ) gen . WriteCommonUtilsHeader ( "gpu/command_buffer/common/gles2_cmd_utils_autogen.h" ) gen . WriteCommonUtilsImpl ( "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" ) gen . WriteGLES2Header ( "gpu/GLES2/gl2chromium_autogen.h" ) mojo_gles2_prefix = "mojo/public/c/gles2/gles2_call_visitor" gen . WriteMojoGLCallVisitor ( mojo_gles2_prefix + "_autogen.h" ) gen . WriteMojoGLCallVisitorForExtension ( mojo_gles2_prefix + "_chromium_texture_mailbox_autogen.h" , "CHROMIUM_texture_mailbox" ) gen . WriteMojoGLCallVisitorForExtension ( mojo_gles2_prefix + "_chromium_sync_point_autogen.h" , "CHROMIUM_sync_point" ) Format ( gen . generated_cpp_filenames ) if gen . errors > 0 : print "%d errors" % gen . errors return 1 return 0
short_docstring: This is the main function.
short_docstring_tokens: This is the main function .
comment: """This is the main function."""$SEP$# Add in states and capabilites to GLState$SEP$# This script lives under gpu/command_buffer, cd to base directory.$SEP$# Support generating files under gen/