| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(): |
| 55 upper_camel = property['upper_camel_name'] | 55 upper_camel = property['upper_camel_name'] |
| 56 set_if_none(property, 'name_for_methods', upper_camel.replace('Webki
t', '')) | 56 set_if_none(property, 'name_for_methods', upper_camel.replace('Webki
t', '')) |
| 57 name = property['name_for_methods'] | 57 name = property['name_for_methods'] |
| 58 simple_type_name = str(property['type_name']).split('::')[-1] | 58 simple_type_name = str(property['type_name']).split('::')[-1] |
| 59 set_if_none(property, 'type_name', 'E' + name) | 59 set_if_none(property, 'type_name', 'E' + name) |
| 60 set_if_none(property, 'getter', lower_first(name) if simple_type_nam
e != name else 'get' + name) | 60 set_if_none(property, 'getter', name if simple_type_name != name els
e 'Get' + name) |
| 61 set_if_none(property, 'setter', 'set' + name) | 61 set_if_none(property, 'setter', 'Set' + name) |
| 62 set_if_none(property, 'inherited', False) | 62 set_if_none(property, 'inherited', False) |
| 63 set_if_none(property, 'initial', 'initial' + name) | 63 set_if_none(property, 'initial', 'Initial' + name) |
| 64 if property['custom_all']: | 64 if property['custom_all']: |
| 65 property['custom_initial'] = True | 65 property['custom_initial'] = True |
| 66 property['custom_inherit'] = True | 66 property['custom_inherit'] = True |
| 67 property['custom_value'] = True | 67 property['custom_value'] = True |
| 68 if property['inherited']: | 68 if property['inherited']: |
| 69 property['is_inherited_setter'] = 'set' + name + 'IsInherited' | 69 property['is_inherited_setter'] = 'Set' + name + 'IsInherited' |
| 70 property['should_declare_functions'] = not property['use_handlers_fo
r'] and not property['longhands'] \ | 70 property['should_declare_functions'] = not property['use_handlers_fo
r'] and not property['longhands'] \ |
| 71 and not property['direction_aware'] and not property['builder_sk
ip'] \ | 71 and not property['direction_aware'] and not property['builder_sk
ip'] \ |
| 72 and property['is_property'] | 72 and property['is_property'] |
| 73 | 73 |
| 74 @template_expander.use_jinja('StyleBuilderFunctions.h.tmpl', | 74 @template_expander.use_jinja('StyleBuilderFunctions.h.tmpl', |
| 75 filters=filters) | 75 filters=filters) |
| 76 def generate_style_builder_functions_h(self): | 76 def generate_style_builder_functions_h(self): |
| 77 return { | 77 return { |
| 78 'properties': self._properties, | 78 'properties': self._properties, |
| 79 } | 79 } |
| 80 | 80 |
| 81 @template_expander.use_jinja('StyleBuilderFunctions.cpp.tmpl', | 81 @template_expander.use_jinja('StyleBuilderFunctions.cpp.tmpl', |
| 82 filters=filters) | 82 filters=filters) |
| 83 def generate_style_builder_functions_cpp(self): | 83 def generate_style_builder_functions_cpp(self): |
| 84 return { | 84 return { |
| 85 'properties': self._properties, | 85 'properties': self._properties, |
| 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 json5_generator.Maker(StyleBuilderWriter).main() | 96 json5_generator.Maker(StyleBuilderWriter).main() |
| OLD | NEW |