parameters: (filename, root, destdir, namespace)
return_statement: return '\n'.join(output_code)
docstring: Generates C++ features files from the json file |filename|.
docstring_summary: Generates C++ features files from the json file |filename|.
docstring_tokens: Generates C ++ features files from the json file |filename| .
function: def _GenerateSchema(filename, root, destdir, namespace):
    """Generates C++ features files from the json file |filename|.
    """
    # Load in the feature permissions from the JSON file.
    schema = os.path.normpath(filename)
    schema_loader = SchemaLoader(os.path.dirname(os.path.relpath(schema, root)),
                                 os.path.dirname(schema),
                                 [],
                                 None)
    schema_filename = os.path.splitext(schema)[0]
    feature_defs = schema_loader.LoadSchema(schema)
  
    # Generate a list of the features defined and a list of their models.
    feature_list = []
    for feature_def, feature in feature_defs.iteritems():
      feature_list.append(CreateFeature(feature_def, feature))
  
    source_file_dir, _ = os.path.split(schema)
    relpath = os.path.relpath(os.path.normpath(source_file_dir), root)
    full_path = os.path.join(relpath, schema)
  
    generators = [
        ('%s.cc' % schema_filename, CCGenerator()),
        ('%s.h' % schema_filename, HGenerator())
    ]
  
    # Generate and output the code for all features.
    output_code = []
    for filename, generator in generators:
      code = generator.Generate(feature_list, full_path, namespace).Render()
      if destdir:
        with open(os.path.join(destdir, relpath, filename), 'w') as f:
          f.write(code)
      output_code += [filename, '', code, '']
  
    return '\n'.join(output_code)
function_tokens: def _GenerateSchema ( filename , root , destdir , namespace ) : # Load in the feature permissions from the JSON file. schema = os . path . normpath ( filename ) schema_loader = SchemaLoader ( os . path . dirname ( os . path . relpath ( schema , root ) ) , os . path . dirname ( schema ) , [ ] , None ) schema_filename = os . path . splitext ( schema ) [ 0 ] feature_defs = schema_loader . LoadSchema ( schema ) # Generate a list of the features defined and a list of their models. feature_list = [ ] for feature_def , feature in feature_defs . iteritems ( ) : feature_list . append ( CreateFeature ( feature_def , feature ) ) source_file_dir , _ = os . path . split ( schema ) relpath = os . path . relpath ( os . path . normpath ( source_file_dir ) , root ) full_path = os . path . join ( relpath , schema ) generators = [ ( '%s.cc' % schema_filename , CCGenerator ( ) ) , ( '%s.h' % schema_filename , HGenerator ( ) ) ] # Generate and output the code for all features. output_code = [ ] for filename , generator in generators : code = generator . Generate ( feature_list , full_path , namespace ) . Render ( ) if destdir : with open ( os . path . join ( destdir , relpath , filename ) , 'w' ) as f : f . write ( code ) output_code += [ filename , '' , code , '' ] return '\n' . join ( output_code )