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 18 matching lines...) Expand all Loading... |
29 | 29 |
30 """Generate template values for an interface. | 30 """Generate template values for an interface. |
31 | 31 |
32 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler | 32 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler |
33 """ | 33 """ |
34 | 34 |
35 from collections import defaultdict | 35 from collections import defaultdict |
36 import itertools | 36 import itertools |
37 from operator import itemgetter | 37 from operator import itemgetter |
38 | 38 |
| 39 import idl_definitions |
| 40 from idl_definitions import IdlOperation |
39 import idl_types | 41 import idl_types |
40 from idl_types import IdlType, inherits_interface | 42 from idl_types import IdlType, inherits_interface |
41 import v8_attributes | 43 import v8_attributes |
42 from v8_globals import includes | 44 from v8_globals import includes |
43 import v8_methods | 45 import v8_methods |
44 import v8_types | 46 import v8_types |
45 from v8_types import cpp_ptr_type, cpp_template_type | 47 from v8_types import cpp_ptr_type, cpp_template_type |
46 import v8_utilities | 48 import v8_utilities |
47 from v8_utilities import capitalize, conditional_string, cpp_name, gc_type, has_
extended_attribute_value, runtime_enabled_function_name | 49 from v8_utilities import capitalize, conditional_string, cpp_name, gc_type, has_
extended_attribute_value, runtime_enabled_function_name |
48 | 50 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 'has_per_context_enabled_attributes': any(attribute['per_context_enabled
_function'] for attribute in attributes), | 247 'has_per_context_enabled_attributes': any(attribute['per_context_enabled
_function'] for attribute in attributes), |
246 'has_replaceable_attributes': any(attribute['is_replaceable'] for attrib
ute in attributes), | 248 'has_replaceable_attributes': any(attribute['is_replaceable'] for attrib
ute in attributes), |
247 }) | 249 }) |
248 | 250 |
249 # Methods | 251 # Methods |
250 methods = [v8_methods.method_context(interface, method) | 252 methods = [v8_methods.method_context(interface, method) |
251 for method in interface.operations | 253 for method in interface.operations |
252 if method.name] # Skip anonymous special operations (methods) | 254 if method.name] # Skip anonymous special operations (methods) |
253 compute_method_overloads_context(methods) | 255 compute_method_overloads_context(methods) |
254 | 256 |
| 257 # Stringifier |
| 258 if interface.stringifier: |
| 259 stringifier = interface.stringifier |
| 260 method = IdlOperation() |
| 261 method.name = 'toString' |
| 262 method.idl_type = IdlType('DOMString') |
| 263 method.extended_attributes.update(stringifier.extended_attributes) |
| 264 if stringifier.attribute: |
| 265 method.extended_attributes['ImplementedAs'] = stringifier.attribute.
name |
| 266 elif stringifier.operation: |
| 267 method.extended_attributes['ImplementedAs'] = stringifier.operation.
name |
| 268 methods.append(v8_methods.method_context(interface, method)) |
| 269 |
255 per_context_enabled_methods = [] | 270 per_context_enabled_methods = [] |
256 custom_registration_methods = [] | 271 custom_registration_methods = [] |
257 method_configuration_methods = [] | 272 method_configuration_methods = [] |
258 | 273 |
259 for method in methods: | 274 for method in methods: |
260 # Skip all but one method in each set of overloaded methods. | 275 # Skip all but one method in each set of overloaded methods. |
261 if 'overload_index' in method and 'overloads' not in method: | 276 if 'overload_index' in method and 'overloads' not in method: |
262 continue | 277 continue |
263 | 278 |
264 if 'overloads' in method: | 279 if 'overloads' in method: |
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 deleter = next( | 1091 deleter = next( |
1077 method | 1092 method |
1078 for method in interface.operations | 1093 for method in interface.operations |
1079 if ('deleter' in method.specials and | 1094 if ('deleter' in method.specials and |
1080 len(method.arguments) == 1 and | 1095 len(method.arguments) == 1 and |
1081 str(method.arguments[0].idl_type) == 'DOMString')) | 1096 str(method.arguments[0].idl_type) == 'DOMString')) |
1082 except StopIteration: | 1097 except StopIteration: |
1083 return None | 1098 return None |
1084 | 1099 |
1085 return property_deleter(deleter) | 1100 return property_deleter(deleter) |
OLD | NEW |