michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: # Write out a C++ enum definition whose members are the names of michael@0: # histograms. The histograms are defined in a file provided as a michael@0: # command-line argument. michael@0: michael@0: import sys michael@0: import histogram_tools michael@0: michael@0: banner = """/* This file is auto-generated, see gen-histogram-enum.py. */ michael@0: """ michael@0: michael@0: def main(argv): michael@0: filename = argv[0] michael@0: michael@0: print banner michael@0: print "enum ID {" michael@0: for histogram in histogram_tools.from_file(filename): michael@0: cpp_guard = histogram.cpp_guard() michael@0: if cpp_guard: michael@0: print "#if defined(%s)" % cpp_guard michael@0: print " %s," % histogram.name() michael@0: if cpp_guard: michael@0: print "#endif" michael@0: print " HistogramCount" michael@0: print "};" michael@0: michael@0: main(sys.argv[1:])