| OLD | NEW |
| 1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
| 2 # coding=utf-8 | 2 # coding=utf-8 |
| 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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 'has_custom_constructor': bool(custom_constructors), | 241 'has_custom_constructor': bool(custom_constructors), |
| 242 'has_event_constructor': has_event_constructor, | 242 'has_event_constructor': has_event_constructor, |
| 243 'interface_length': | 243 'interface_length': |
| 244 interface_length(interface, constructors + custom_constructors), | 244 interface_length(interface, constructors + custom_constructors), |
| 245 'is_constructor_raises_exception': extended_attributes.get('RaisesExcept
ion') == 'Constructor', # [RaisesException=Constructor] | 245 'is_constructor_raises_exception': extended_attributes.get('RaisesExcept
ion') == 'Constructor', # [RaisesException=Constructor] |
| 246 'named_constructor': named_constructor, | 246 'named_constructor': named_constructor, |
| 247 }) | 247 }) |
| 248 | 248 |
| 249 constants = [constant_context(constant) for constant in interface.constants] | 249 constants = [constant_context(constant) for constant in interface.constants] |
| 250 | 250 |
| 251 special_getter_constants = [] |
| 252 runtime_enabled_constants = [] |
| 253 constant_configuration_constants = [] |
| 254 |
| 255 for constant in constants: |
| 256 if constant['measure_as'] or constant['deprecate_as']: |
| 257 special_getter_constants.append(constant) |
| 258 continue |
| 259 if constant['runtime_enabled_function']: |
| 260 runtime_enabled_constants.append(constant) |
| 261 continue |
| 262 constant_configuration_constants.append(constant) |
| 263 |
| 251 # Constants | 264 # Constants |
| 252 context.update({ | 265 context.update({ |
| 266 'constant_configuration_constants': constant_configuration_constants, |
| 253 'constants': constants, | 267 'constants': constants, |
| 254 'do_not_check_constants': 'DoNotCheckConstants' in extended_attributes, | 268 'do_not_check_constants': 'DoNotCheckConstants' in extended_attributes, |
| 255 'has_constant_configuration': any( | 269 'has_constant_configuration': any( |
| 256 not constant['runtime_enabled_function'] | 270 not constant['runtime_enabled_function'] |
| 257 for constant in constants), | 271 for constant in constants), |
| 272 'runtime_enabled_constants': runtime_enabled_constants, |
| 273 'special_getter_constants': special_getter_constants, |
| 258 }) | 274 }) |
| 259 | 275 |
| 260 # Attributes | 276 # Attributes |
| 261 attributes = [v8_attributes.attribute_context(interface, attribute) | 277 attributes = [v8_attributes.attribute_context(interface, attribute) |
| 262 for attribute in interface.attributes] | 278 for attribute in interface.attributes] |
| 263 context.update({ | 279 context.update({ |
| 264 'attributes': attributes, | 280 'attributes': attributes, |
| 265 'has_accessors': any(attribute['is_expose_js_accessors'] and attribute['
should_be_exposed_to_script'] for attribute in attributes), | 281 'has_accessors': any(attribute['is_expose_js_accessors'] and attribute['
should_be_exposed_to_script'] for attribute in attributes), |
| 266 'has_attribute_configuration': any( | 282 'has_attribute_configuration': any( |
| 267 not (attribute['is_expose_js_accessors'] or | 283 not (attribute['is_expose_js_accessors'] or |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 'named_property_getter': named_property_getter(interface), | 375 'named_property_getter': named_property_getter(interface), |
| 360 'named_property_setter': named_property_setter(interface), | 376 'named_property_setter': named_property_setter(interface), |
| 361 'named_property_deleter': named_property_deleter(interface), | 377 'named_property_deleter': named_property_deleter(interface), |
| 362 }) | 378 }) |
| 363 | 379 |
| 364 return context | 380 return context |
| 365 | 381 |
| 366 | 382 |
| 367 # [DeprecateAs], [Reflect], [RuntimeEnabled] | 383 # [DeprecateAs], [Reflect], [RuntimeEnabled] |
| 368 def constant_context(constant): | 384 def constant_context(constant): |
| 369 # (Blink-only) string literals are unquoted in tokenizer, must be re-quoted | |
| 370 # in C++. | |
| 371 if constant.idl_type.name == 'String': | |
| 372 value = '"%s"' % constant.value | |
| 373 else: | |
| 374 value = constant.value | |
| 375 | |
| 376 extended_attributes = constant.extended_attributes | 385 extended_attributes = constant.extended_attributes |
| 377 return { | 386 return { |
| 378 'cpp_class': extended_attributes.get('PartialInterfaceImplementedAs'), | 387 'cpp_class': extended_attributes.get('PartialInterfaceImplementedAs'), |
| 388 'deprecate_as': v8_utilities.deprecate_as(constant), # [DeprecateAs] |
| 379 'idl_type': constant.idl_type.name, | 389 'idl_type': constant.idl_type.name, |
| 390 'measure_as': v8_utilities.measure_as(constant), # [MeasureAs] |
| 380 'name': constant.name, | 391 'name': constant.name, |
| 381 # FIXME: use 'reflected_name' as correct 'name' | 392 # FIXME: use 'reflected_name' as correct 'name' |
| 382 'reflected_name': extended_attributes.get('Reflect', constant.name), | 393 'reflected_name': extended_attributes.get('Reflect', constant.name), |
| 383 'runtime_enabled_function': runtime_enabled_function_name(constant), | 394 'runtime_enabled_function': runtime_enabled_function_name(constant), |
| 384 'value': value, | 395 'value': constant.value, |
| 385 } | 396 } |
| 386 | 397 |
| 387 | 398 |
| 388 ################################################################################ | 399 ################################################################################ |
| 389 # Overloads | 400 # Overloads |
| 390 ################################################################################ | 401 ################################################################################ |
| 391 | 402 |
| 392 def compute_method_overloads_context(methods): | 403 def compute_method_overloads_context(methods): |
| 393 # Regular methods | 404 # Regular methods |
| 394 compute_method_overloads_context_by_type([method for method in methods | 405 compute_method_overloads_context_by_type([method for method in methods |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1146 deleter = next( | 1157 deleter = next( |
| 1147 method | 1158 method |
| 1148 for method in interface.operations | 1159 for method in interface.operations |
| 1149 if ('deleter' in method.specials and | 1160 if ('deleter' in method.specials and |
| 1150 len(method.arguments) == 1 and | 1161 len(method.arguments) == 1 and |
| 1151 str(method.arguments[0].idl_type) == 'DOMString')) | 1162 str(method.arguments[0].idl_type) == 'DOMString')) |
| 1152 except StopIteration: | 1163 except StopIteration: |
| 1153 return None | 1164 return None |
| 1154 | 1165 |
| 1155 return property_deleter(deleter) | 1166 return property_deleter(deleter) |
| OLD | NEW |