| 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 29 matching lines...) Expand all Loading... |
| 40 import re | 40 import re |
| 41 import v8_types | 41 import v8_types |
| 42 | 42 |
| 43 ACRONYMS = ['CSS', 'HTML', 'IME', 'JS', 'SVG', 'URL', 'WOFF', 'XML', 'XSLT'] | 43 ACRONYMS = ['CSS', 'HTML', 'IME', 'JS', 'SVG', 'URL', 'WOFF', 'XML', 'XSLT'] |
| 44 | 44 |
| 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 |
| 51 return (key in extended_attributes and | 51 def extended_attribute_value_contains(extended_attribute_value, value): |
| 52 value in re.split('[|&]', extended_attributes[key])) | 52 return value in re.split('[|&]', extended_attribute_value) |
| 53 | 53 |
| 54 | 54 |
| 55 def capitalize(name): | 55 def capitalize(name): |
| 56 """Capitalize first letter or initial acronym (used in setter names).""" | 56 """Capitalize first letter or initial acronym (used in setter names).""" |
| 57 for acronym in ACRONYMS: | 57 for acronym in ACRONYMS: |
| 58 if name.startswith(acronym.lower()): | 58 if name.startswith(acronym.lower()): |
| 59 return name.replace(acronym.lower(), acronym) | 59 return name.replace(acronym.lower(), acronym) |
| 60 return name[0].upper() + name[1:] | 60 return name[0].upper() + name[1:] |
| 61 | 61 |
| 62 | 62 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 # List because key order matters, as we want arguments in deterministic order | 111 # List because key order matters, as we want arguments in deterministic order |
| 112 CALL_WITH_VALUES = [ | 112 CALL_WITH_VALUES = [ |
| 113 'ScriptState', | 113 'ScriptState', |
| 114 'ExecutionContext', | 114 'ExecutionContext', |
| 115 'ScriptArguments', | 115 'ScriptArguments', |
| 116 'ActiveWindow', | 116 'ActiveWindow', |
| 117 'FirstWindow', | 117 'FirstWindow', |
| 118 ] | 118 ] |
| 119 | 119 |
| 120 | 120 |
| 121 def call_with_arguments(member, contents): | 121 def call_with_arguments(call_with, contents): |
| 122 extended_attributes = member.extended_attributes | 122 # FIXME: Implement other template values for functions |
| 123 if 'CallWith' not in extended_attributes: | 123 contents['is_call_with_script_execution_context'] = extended_attribute_value
_contains(call_with, 'ExecutionContext') |
| 124 return [] | |
| 125 | |
| 126 # FIXME: Implement other template values for setters and functions | |
| 127 contents['is_call_with_script_execution_context'] = has_extended_attribute_v
alue(extended_attributes, 'CallWith', 'ExecutionContext') | |
| 128 | 124 |
| 129 return [CALL_WITH_ARGUMENTS[value] | 125 return [CALL_WITH_ARGUMENTS[value] |
| 130 for value in CALL_WITH_VALUES | 126 for value in CALL_WITH_VALUES |
| 131 if has_extended_attribute_value(extended_attributes, 'CallWith', val
ue)] | 127 if extended_attribute_value_contains(call_with, value)] |
| 132 | 128 |
| 133 | 129 |
| 134 # [Conditional] | 130 # [Conditional] |
| 135 def generate_conditional_string(definition_or_member): | 131 def generate_conditional_string(definition_or_member): |
| 136 if 'Conditional' not in definition_or_member.extended_attributes: | 132 if 'Conditional' not in definition_or_member.extended_attributes: |
| 137 return None | 133 return None |
| 138 conditional = definition_or_member.extended_attributes['Conditional'] | 134 conditional = definition_or_member.extended_attributes['Conditional'] |
| 139 for operator in '&|': | 135 for operator in '&|': |
| 140 if operator in conditional: | 136 if operator in conditional: |
| 141 conditions = set(conditional.split(operator)) | 137 conditions = set(conditional.split(operator)) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 def cpp_name(definition_or_member): | 177 def cpp_name(definition_or_member): |
| 182 return definition_or_member.extended_attributes.get('ImplementedAs', definit
ion_or_member.name) | 178 return definition_or_member.extended_attributes.get('ImplementedAs', definit
ion_or_member.name) |
| 183 | 179 |
| 184 | 180 |
| 185 # [MeasureAs] | 181 # [MeasureAs] |
| 186 def generate_measure_as(definition_or_member, contents, includes): | 182 def generate_measure_as(definition_or_member, contents, includes): |
| 187 if 'MeasureAs' not in definition_or_member.extended_attributes: | 183 if 'MeasureAs' not in definition_or_member.extended_attributes: |
| 188 return | 184 return |
| 189 contents['measure_as'] = definition_or_member.extended_attributes['MeasureAs
'] | 185 contents['measure_as'] = definition_or_member.extended_attributes['MeasureAs
'] |
| 190 includes.add('core/page/UseCounter.h') | 186 includes.add('core/page/UseCounter.h') |
| OLD | NEW |