| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (C) 2013 Google Inc. All rights reserved. | 2 # Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 # | 3 # |
| 4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
| 5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
| 6 # met: | 6 # met: |
| 7 # | 7 # |
| 8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
| 9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
| 10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | 29 |
| 30 import sys | 30 import sys |
| 31 | 31 |
| 32 import css_properties | 32 import css_properties |
| 33 import in_generator | 33 import json5_generator |
| 34 from name_utilities import lower_first | 34 from name_utilities import lower_first |
| 35 import template_expander | 35 import template_expander |
| 36 | 36 |
| 37 | 37 |
| 38 class StyleBuilderWriter(css_properties.CSSProperties): | 38 class StyleBuilderWriter(css_properties.CSSProperties): |
| 39 filters = { | 39 filters = { |
| 40 'lower_first': lower_first, | 40 'lower_first': lower_first, |
| 41 } | 41 } |
| 42 | 42 |
| 43 def __init__(self, in_file_path): | 43 def __init__(self, json5_file_path): |
| 44 super(StyleBuilderWriter, self).__init__(in_file_path) | 44 super(StyleBuilderWriter, self).__init__(json5_file_path) |
| 45 self._outputs = {('StyleBuilderFunctions.h'): self.generate_style_builde
r_functions_h, | 45 self._outputs = {('StyleBuilderFunctions.h'): self.generate_style_builde
r_functions_h, |
| 46 ('StyleBuilderFunctions.cpp'): self.generate_style_buil
der_functions_cpp, | 46 ('StyleBuilderFunctions.cpp'): self.generate_style_buil
der_functions_cpp, |
| 47 ('StyleBuilder.cpp'): self.generate_style_builder, | 47 ('StyleBuilder.cpp'): self.generate_style_builder, |
| 48 } | 48 } |
| 49 | 49 |
| 50 def set_if_none(property, key, value): | 50 def set_if_none(property, key, value): |
| 51 if property[key] is None: | 51 if property[key] is None: |
| 52 property[key] = value | 52 property[key] = value |
| 53 | 53 |
| 54 for property in self._properties.values(): | 54 for property in self._properties.values(): |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 } | 86 } |
| 87 | 87 |
| 88 @template_expander.use_jinja('StyleBuilder.cpp.tmpl', filters=filters) | 88 @template_expander.use_jinja('StyleBuilder.cpp.tmpl', filters=filters) |
| 89 def generate_style_builder(self): | 89 def generate_style_builder(self): |
| 90 return { | 90 return { |
| 91 'properties': self._properties, | 91 'properties': self._properties, |
| 92 } | 92 } |
| 93 | 93 |
| 94 | 94 |
| 95 if __name__ == '__main__': | 95 if __name__ == '__main__': |
| 96 in_generator.Maker(StyleBuilderWriter).main(sys.argv) | 96 json5_generator.Maker(StyleBuilderWriter).main() |
| OLD | NEW |