toolkit/components/telemetry/gen-histogram-enum.py

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/telemetry/gen-histogram-enum.py	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,30 @@
     1.4 +# This Source Code Form is subject to the terms of the Mozilla Public
     1.5 +# License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.7 +
     1.8 +# Write out a C++ enum definition whose members are the names of
     1.9 +# histograms.  The histograms are defined in a file provided as a
    1.10 +# command-line argument.
    1.11 +
    1.12 +import sys
    1.13 +import histogram_tools
    1.14 +
    1.15 +banner = """/* This file is auto-generated, see gen-histogram-enum.py.  */
    1.16 +"""
    1.17 +
    1.18 +def main(argv):
    1.19 +    filename = argv[0]
    1.20 +
    1.21 +    print banner
    1.22 +    print "enum ID {"
    1.23 +    for histogram in histogram_tools.from_file(filename):
    1.24 +        cpp_guard = histogram.cpp_guard()
    1.25 +        if cpp_guard:
    1.26 +            print "#if defined(%s)" % cpp_guard
    1.27 +        print "  %s," % histogram.name()
    1.28 +        if cpp_guard:
    1.29 +            print "#endif"
    1.30 +    print "  HistogramCount"
    1.31 +    print "};"
    1.32 +
    1.33 +main(sys.argv[1:])

mercurial