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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 def has_extended_attribute(definition_or_member, extended_attribute_list): | 46 def has_extended_attribute(definition_or_member, extended_attribute_list): |
47 return any(extended_attribute in definition_or_member.extended_attributes | 47 return any(extended_attribute in definition_or_member.extended_attributes |
48 for extended_attribute in extended_attribute_list) | 48 for extended_attribute in extended_attribute_list) |
49 | 49 |
50 def has_extended_attribute_value(extended_attributes, key, value): | 50 def has_extended_attribute_value(extended_attributes, key, value): |
51 return (key in extended_attributes and | 51 return (key in extended_attributes and |
52 value in re.split('[|&]', extended_attributes[key])) | 52 value in re.split('[|&]', extended_attributes[key])) |
53 | 53 |
54 | 54 |
| 55 def capitalize(name): |
| 56 """Capitalize first letter or initial acronym (* with some exceptions). |
| 57 |
| 58 Used in setter names. |
| 59 """ |
| 60 name = name[0].upper() + name[1:] |
| 61 # xmlEncoding becomes XMLEncoding, but xmlllang becomes Xmllang. |
| 62 # FIXME: Remove these special cases |
| 63 if name.startswith('CssText') or re.match('Xml[a-z]', name): |
| 64 return name |
| 65 for acronym in ACRONYMS: |
| 66 if name.startswith(acronym.capitalize()): |
| 67 name.replace(acronym.capitalize(), acronym) |
| 68 return name |
| 69 return name |
| 70 |
| 71 |
55 def uncapitalize(name): | 72 def uncapitalize(name): |
56 """Uncapitalizes first letter or initial acronym (* with some exceptions). | 73 """Uncapitalizes first letter or initial acronym (* with some exceptions). |
57 | 74 |
58 E.g., 'SetURL' becomes 'setURL', but 'URLFoo' becomes 'urlFoo'. | 75 E.g., 'SetURL' becomes 'setURL', but 'URLFoo' becomes 'urlFoo'. |
59 Used in method names; exceptions differ from capitalize(). | 76 Used in method names; exceptions differ from capitalize(). |
60 """ | 77 """ |
61 for acronym in ACRONYMS: | 78 for acronym in ACRONYMS: |
62 if name.startswith(acronym): | 79 if name.startswith(acronym): |
63 name.replace(acronym, acronym.lower()) | 80 name.replace(acronym, acronym.lower()) |
64 return name | 81 return name |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 def cpp_name(definition_or_member): | 190 def cpp_name(definition_or_member): |
174 return definition_or_member.extended_attributes.get('ImplementedAs', definit
ion_or_member.name) | 191 return definition_or_member.extended_attributes.get('ImplementedAs', definit
ion_or_member.name) |
175 | 192 |
176 | 193 |
177 # [MeasureAs] | 194 # [MeasureAs] |
178 def generate_measure_as(definition_or_member, contents, includes): | 195 def generate_measure_as(definition_or_member, contents, includes): |
179 if 'MeasureAs' not in definition_or_member.extended_attributes: | 196 if 'MeasureAs' not in definition_or_member.extended_attributes: |
180 return | 197 return |
181 contents['measure_as'] = definition_or_member.extended_attributes['MeasureAs
'] | 198 contents['measure_as'] = definition_or_member.extended_attributes['MeasureAs
'] |
182 includes.add('core/page/UseCounter.h') | 199 includes.add('core/page/UseCounter.h') |
OLD | NEW |