original_docstring: Writes the service context state header.
docstring: Writes the service context state header.
docstring_tokens: Writes the service context state header .
code: def WriteServiceContextStateHeader(self, filename):
      """Writes the service context state header."""
      file = CHeaderWriter(
          filename,
          "// It is included by context_state.h\n")
      file.Write("struct EnableFlags {\n")
      file.Write("  EnableFlags();\n")
      for capability in _CAPABILITY_FLAGS:
        file.Write("  bool %s;\n" % capability['name'])
        file.Write("  bool cached_%s;\n" % capability['name'])
      file.Write("};\n\n")
  
      for state_name in sorted(_STATES.keys()):
        state = _STATES[state_name]
        for item in state['states']:
          if isinstance(item['default'], list):
            file.Write("%s %s[%d];\n" % (item['type'], item['name'],
                                         len(item['default'])))
          else:
            file.Write("%s %s;\n" % (item['type'], item['name']))
  
          if item.get('cached', False):
            if isinstance(item['default'], list):
              file.Write("%s cached_%s[%d];\n" % (item['type'], item['name'],
                                                  len(item['default'])))
            else:
              file.Write("%s cached_%s;\n" % (item['type'], item['name']))
  
      file.Write("\n")
  
      file.Write("""
          inline void SetDeviceCapabilityState(GLenum cap, bool enable) {
            switch (cap) {
          """)
      for capability in _CAPABILITY_FLAGS:
        file.Write("""\
              case GL_%s:
            """ % capability['name'].upper())
        file.Write("""\
                if (enable_flags.cached_%(name)s == enable &&
                    !ignore_cached_state)
                  return;
                enable_flags.cached_%(name)s = enable;
                break;
            """ % capability)
  
      file.Write("""\
              default:
                NOTREACHED();
                return;
            }
            if (enable)
              glEnable(cap);
            else
              glDisable(cap);
          }
          """)
  
      file.Close()
      self.generated_cpp_filenames.append(file.filename)
code_tokens: def WriteServiceContextStateHeader ( self , filename ) : file = CHeaderWriter ( filename , "// It is included by context_state.h\n" ) file . Write ( "struct EnableFlags {\n" ) file . Write ( "  EnableFlags();\n" ) for capability in _CAPABILITY_FLAGS : file . Write ( "  bool %s;\n" % capability [ 'name' ] ) file . Write ( "  bool cached_%s;\n" % capability [ 'name' ] ) file . Write ( "};\n\n" ) for state_name in sorted ( _STATES . keys ( ) ) : state = _STATES [ state_name ] for item in state [ 'states' ] : if isinstance ( item [ 'default' ] , list ) : file . Write ( "%s %s[%d];\n" % ( item [ 'type' ] , item [ 'name' ] , len ( item [ 'default' ] ) ) ) else : file . Write ( "%s %s;\n" % ( item [ 'type' ] , item [ 'name' ] ) ) if item . get ( 'cached' , False ) : if isinstance ( item [ 'default' ] , list ) : file . Write ( "%s cached_%s[%d];\n" % ( item [ 'type' ] , item [ 'name' ] , len ( item [ 'default' ] ) ) ) else : file . Write ( "%s cached_%s;\n" % ( item [ 'type' ] , item [ 'name' ] ) ) file . Write ( "\n" ) file . Write ( """
          inline void SetDeviceCapabilityState(GLenum cap, bool enable) {
            switch (cap) {
          """ ) for capability in _CAPABILITY_FLAGS : file . Write ( """\
              case GL_%s:
            """ % capability [ 'name' ] . upper ( ) ) file . Write ( """\
                if (enable_flags.cached_%(name)s == enable &&
                    !ignore_cached_state)
                  return;
                enable_flags.cached_%(name)s = enable;
                break;
            """ % capability ) file . Write ( """\
              default:
                NOTREACHED();
                return;
            }
            if (enable)
              glEnable(cap);
            else
              glDisable(cap);
          }
          """ ) file . Close ( ) self . generated_cpp_filenames . append ( file . filename )
short_docstring: Writes the service context state header.
short_docstring_tokens: Writes the service context state header .
comment: """Writes the service context state header."""