| OLD | NEW |
| 1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 return _upper_first(name) | 67 return _upper_first(name) |
| 68 | 68 |
| 69 | 69 |
| 70 def _upper_first(name): | 70 def _upper_first(name): |
| 71 """Return name with first letter uppercased.""" | 71 """Return name with first letter uppercased.""" |
| 72 if not name: | 72 if not name: |
| 73 return '' | 73 return '' |
| 74 return name[0].upper() + name[1:] | 74 return name[0].upper() + name[1:] |
| 75 | 75 |
| 76 | 76 |
| 77 def camelcase_property_name(property_name): | |
| 78 """Convert hyphen-separated-name to UpperCamelCase. | |
| 79 | |
| 80 E.g., '-foo-bar' becomes 'FooBar'. | |
| 81 Used for CSS property names. | |
| 82 """ | |
| 83 return ''.join(_upper_first(word) for word in property_name.split('-')) | |
| 84 | |
| 85 | |
| 86 def to_macro_style(name): | 77 def to_macro_style(name): |
| 87 s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) | 78 s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) |
| 88 return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).upper() | 79 return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).upper() |
| 89 | 80 |
| 90 | 81 |
| 91 def script_name(entry): | 82 def script_name(entry): |
| 92 return os.path.basename(entry['name']) | 83 return os.path.basename(entry['name']) |
| 93 | 84 |
| 94 | 85 |
| 95 def cpp_name(entry): | 86 def cpp_name(entry): |
| 96 return entry['ImplementedAs'] or script_name(entry) | 87 return entry['ImplementedAs'] or script_name(entry) |
| 97 | 88 |
| 98 | 89 |
| 99 def enable_conditional_if_endif(code, feature): | 90 def enable_conditional_if_endif(code, feature): |
| 100 # Jinja2 filter to generate if/endif directive blocks based on a feature | 91 # Jinja2 filter to generate if/endif directive blocks based on a feature |
| 101 if not feature: | 92 if not feature: |
| 102 return code | 93 return code |
| 103 condition = 'ENABLE(%s)' % feature | 94 condition = 'ENABLE(%s)' % feature |
| 104 return ('#if %s\n' % condition + | 95 return ('#if %s\n' % condition + |
| 105 code + | 96 code + |
| 106 '#endif // %s\n' % condition) | 97 '#endif // %s\n' % condition) |
| OLD | NEW |