| OLD | NEW |
| (Empty) | |
| 1 #!/usr/bin/env python |
| 2 |
| 3 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. |
| 6 |
| 7 import media_feature_symbol |
| 8 import in_generator |
| 9 import template_expander |
| 10 import name_utilities |
| 11 import sys |
| 12 |
| 13 |
| 14 feature_count = 0 |
| 15 |
| 16 |
| 17 def increment(value): |
| 18 global feature_count |
| 19 if (value): |
| 20 feature_count = int(value) |
| 21 else: |
| 22 feature_count += 1 |
| 23 return feature_count |
| 24 |
| 25 |
| 26 class MakeUseCounterWriter(in_generator.Writer): |
| 27 defaults = { |
| 28 'value': None, |
| 29 } |
| 30 filters = { |
| 31 'increment': increment, |
| 32 } |
| 33 default_parameters = { |
| 34 'value': '', |
| 35 } |
| 36 |
| 37 def __init__(self, in_file_path): |
| 38 super(MakeUseCounterWriter, self).__init__(in_file_path) |
| 39 |
| 40 self._outputs = { |
| 41 ('UseCounterGenerated.h'): self.generate_header, |
| 42 } |
| 43 self._template_context = { |
| 44 'features': self.in_file.name_dictionaries, |
| 45 } |
| 46 |
| 47 @template_expander.use_jinja('UseCounterGenerated.h.tmpl', filters=filters) |
| 48 def generate_header(self): |
| 49 return self._template_context |
| 50 |
| 51 if __name__ == '__main__': |
| 52 in_generator.Maker(MakeUseCounterWriter).main(sys.argv) |
| OLD | NEW |