parameters: (self)
return_statement: return c
docstring: Generates a Code object with the .h for a single namespace.
docstring_summary: Generates a Code object with the .h for a single namespace.
docstring_tokens: Generates a Code object with the . h for a single namespace .
function: def Generate(self):
      """Generates a Code object with the .h for a single namespace.
      """
      c = Code()
      (c.Append(cpp_util.CHROMIUM_LICENSE)
        .Append()
        .Append(cpp_util.GENERATED_FILE_MESSAGE % self._namespace.source_file)
        .Append()
      )
  
      ifndef_name = cpp_util.GenerateIfndefName(self._namespace.source_file_dir,
                                                self._target_namespace)
      (c.Append('#ifndef %s' % ifndef_name)
        .Append('#define %s' % ifndef_name)
        .Append()
        .Append('#include <map>')
        .Append('#include <string>')
        .Append('#include <vector>')
        .Append()
        .Append('#include "base/basictypes.h"')
        .Append('#include "base/logging.h"')
        .Append('#include "base/memory/linked_ptr.h"')
        .Append('#include "base/memory/scoped_ptr.h"')
        .Append('#include "base/values.h"')
        .Cblock(self._type_helper.GenerateIncludes())
        .Append()
      )
  
      c.Concat(cpp_util.OpenNamespace(self._cpp_namespace))
      # TODO(calamity): These forward declarations should be #includes to allow
      # $ref types from other files to be used as required params. This requires
      # some detangling of windows and tabs which will currently lead to circular
      # #includes.
      forward_declarations = (
          self._type_helper.GenerateForwardDeclarations())
      if not forward_declarations.IsEmpty():
        (c.Append()
          .Cblock(forward_declarations)
        )
  
      c.Concat(self._type_helper.GetNamespaceStart())
      c.Append()
      if self._namespace.properties:
        (c.Append('//')
          .Append('// Properties')
          .Append('//')
          .Append()
        )
        for property in self._namespace.properties.values():
          property_code = self._type_helper.GeneratePropertyValues(
              property,
              'extern const %(type)s %(name)s;')
          if property_code:
            c.Cblock(property_code)
      if self._namespace.types:
        (c.Append('//')
          .Append('// Types')
          .Append('//')
          .Append()
          .Cblock(self._GenerateTypes(self._FieldDependencyOrder(),
                                      is_toplevel=True,
                                      generate_typedefs=True))
        )
      if self._namespace.functions:
        (c.Append('//')
          .Append('// Functions')
          .Append('//')
          .Append()
        )
        for function in self._namespace.functions.values():
          c.Cblock(self._GenerateFunction(function))
      if self._namespace.events:
        (c.Append('//')
          .Append('// Events')
          .Append('//')
          .Append()
        )
        for event in self._namespace.events.values():
          c.Cblock(self._GenerateEvent(event))
      (c.Concat(self._type_helper.GetNamespaceEnd())
        .Concat(cpp_util.CloseNamespace(self._cpp_namespace))
        .Append('#endif  // %s' % ifndef_name)
        .Append()
      )
      return c
function_tokens: def Generate ( self ) : c = Code ( ) ( c . Append ( cpp_util . CHROMIUM_LICENSE ) . Append ( ) . Append ( cpp_util . GENERATED_FILE_MESSAGE % self . _namespace . source_file ) . Append ( ) ) ifndef_name = cpp_util . GenerateIfndefName ( self . _namespace . source_file_dir , self . _target_namespace ) ( c . Append ( '#ifndef %s' % ifndef_name ) . Append ( '#define %s' % ifndef_name ) . Append ( ) . Append ( '#include <map>' ) . Append ( '#include <string>' ) . Append ( '#include <vector>' ) . Append ( ) . Append ( '#include "base/basictypes.h"' ) . Append ( '#include "base/logging.h"' ) . Append ( '#include "base/memory/linked_ptr.h"' ) . Append ( '#include "base/memory/scoped_ptr.h"' ) . Append ( '#include "base/values.h"' ) . Cblock ( self . _type_helper . GenerateIncludes ( ) ) . Append ( ) ) c . Concat ( cpp_util . OpenNamespace ( self . _cpp_namespace ) ) # TODO(calamity): These forward declarations should be #includes to allow # $ref types from other files to be used as required params. This requires # some detangling of windows and tabs which will currently lead to circular # #includes. forward_declarations = ( self . _type_helper . GenerateForwardDeclarations ( ) ) if not forward_declarations . IsEmpty ( ) : ( c . Append ( ) . Cblock ( forward_declarations ) ) c . Concat ( self . _type_helper . GetNamespaceStart ( ) ) c . Append ( ) if self . _namespace . properties : ( c . Append ( '//' ) . Append ( '// Properties' ) . Append ( '//' ) . Append ( ) ) for property in self . _namespace . properties . values ( ) : property_code = self . _type_helper . GeneratePropertyValues ( property , 'extern const %(type)s %(name)s;' ) if property_code : c . Cblock ( property_code ) if self . _namespace . types : ( c . Append ( '//' ) . Append ( '// Types' ) . Append ( '//' ) . Append ( ) . Cblock ( self . _GenerateTypes ( self . _FieldDependencyOrder ( ) , is_toplevel = True , generate_typedefs = True ) ) ) if self . _namespace . functions : ( c . Append ( '//' ) . Append ( '// Functions' ) . Append ( '//' ) . Append ( ) ) for function in self . _namespace . functions . values ( ) : c . Cblock ( self . _GenerateFunction ( function ) ) if self . _namespace . events : ( c . Append ( '//' ) . Append ( '// Events' ) . Append ( '//' ) . Append ( ) ) for event in self . _namespace . events . values ( ) : c . Cblock ( self . _GenerateEvent ( event ) ) ( c . Concat ( self . _type_helper . GetNamespaceEnd ( ) ) . Concat ( cpp_util . CloseNamespace ( self . _cpp_namespace ) ) . Append ( '#endif  // %s' % ifndef_name ) . Append ( ) ) return c