OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 from collections import defaultdict |
| 7 import sys |
| 8 |
| 9 import css_properties |
| 10 import in_generator |
| 11 from name_utilities import enum_for_css_property |
| 12 from name_utilities import lower_first |
| 13 import template_expander |
| 14 |
| 15 |
| 16 class CSSPropertyEqualityWriter(css_properties.CSSProperties): |
| 17 filters = { |
| 18 'lower_first': lower_first, |
| 19 } |
| 20 |
| 21 def __init__(self, in_file_path): |
| 22 super(CSSPropertyEqualityWriter, self).__init__(in_file_path) |
| 23 |
| 24 def set_if_none(property, key, value): |
| 25 if property[key] is None: |
| 26 property[key] = value |
| 27 |
| 28 for property in self._properties.values(): |
| 29 upper_camel = property['upper_camel_name'] |
| 30 set_if_none(property, 'name_for_methods', upper_camel.replace('Webki
t', '')) |
| 31 name = property['name_for_methods'] |
| 32 simple_type_name = str(property['type_name']).split('::')[-1] |
| 33 set_if_none(property, 'getter', lower_first(name) if simple_type_nam
e != name else 'get' + name) |
| 34 |
| 35 for property in self._properties.values(): |
| 36 property['longhand_property_ids'] = map(enum_for_css_property, prope
rty['longhands'].split(';')) |
| 37 |
| 38 self._outputs = { |
| 39 'CSSPropertyEquality.cpp': self.generate_property_equality, |
| 40 'CSSPropertyEqualityCustom.h': self.generate_property_equality_custo
m_header, |
| 41 } |
| 42 |
| 43 @template_expander.use_jinja('CSSPropertyEquality.cpp.tmpl') |
| 44 def generate_property_equality(self): |
| 45 return { |
| 46 'properties': self._properties, |
| 47 } |
| 48 |
| 49 @template_expander.use_jinja('CSSPropertyEqualityCustom.h.tmpl') |
| 50 def generate_property_equality_custom_header(self): |
| 51 return { |
| 52 'properties': self._properties, |
| 53 } |
| 54 |
| 55 if __name__ == '__main__': |
| 56 in_generator.Maker(CSSPropertyEqualityWriter).main(sys.argv) |
OLD | NEW |