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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 is_active_dom_object = 'ActiveDOMObject' in extended_attributes | 117 is_active_dom_object = 'ActiveDOMObject' in extended_attributes |
118 | 118 |
119 # [CheckSecurity] | 119 # [CheckSecurity] |
120 is_check_security = 'CheckSecurity' in extended_attributes | 120 is_check_security = 'CheckSecurity' in extended_attributes |
121 if is_check_security: | 121 if is_check_security: |
122 includes.add('bindings/core/v8/BindingSecurity.h') | 122 includes.add('bindings/core/v8/BindingSecurity.h') |
123 | 123 |
124 # [DependentLifetime] | 124 # [DependentLifetime] |
125 is_dependent_lifetime = 'DependentLifetime' in extended_attributes | 125 is_dependent_lifetime = 'DependentLifetime' in extended_attributes |
126 | 126 |
127 # [Iterable], iterable<>, maplike<> and setlike<> | |
128 iterator_method = None | |
129 # FIXME: support Iterable in partial interfaces. However, we don't | |
130 # need to support iterator overloads between interface and | |
131 # partial interface definitions. | |
132 # http://heycam.github.io/webidl/#idl-overloading | |
133 if (not interface.is_partial | |
134 and (interface.iterable or interface.maplike or interface.setlike | |
135 or 'Iterable' in extended_attributes)): | |
136 iterator_operation = IdlOperation(interface.idl_name) | |
137 iterator_operation.name = 'iterator' | |
138 iterator_operation.idl_type = IdlType('Iterator') | |
139 iterator_operation.extended_attributes['RaisesException'] = None | |
140 iterator_operation.extended_attributes['CallWith'] = 'ScriptState' | |
141 iterator_method = v8_methods.method_context(interface, | |
142 iterator_operation) | |
143 # FIXME: iterable<>, maplike<> and setlike<> should also imply the | |
144 # presence of a subset of keys(), values(), entries(), forEach(), has(), | |
145 # get(), add(), set(), delete() and clear(), and a 'size' attribute. | |
146 | |
147 # [MeasureAs] | 127 # [MeasureAs] |
148 is_measure_as = 'MeasureAs' in extended_attributes | 128 is_measure_as = 'MeasureAs' in extended_attributes |
149 if is_measure_as: | 129 if is_measure_as: |
150 includes.add('core/frame/UseCounter.h') | 130 includes.add('core/frame/UseCounter.h') |
151 | 131 |
152 # [SetWrapperReferenceFrom] | 132 # [SetWrapperReferenceFrom] |
153 reachable_node_function = extended_attributes.get('SetWrapperReferenceFrom') | 133 reachable_node_function = extended_attributes.get('SetWrapperReferenceFrom') |
154 if reachable_node_function: | 134 if reachable_node_function: |
155 includes.update(['bindings/core/v8/V8GCController.h', | 135 includes.update(['bindings/core/v8/V8GCController.h', |
156 'core/dom/Element.h']) | 136 'core/dom/Element.h']) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 'header_includes': header_includes, | 181 'header_includes': header_includes, |
202 'interface_name': interface.name, | 182 'interface_name': interface.name, |
203 'is_active_dom_object': is_active_dom_object, | 183 'is_active_dom_object': is_active_dom_object, |
204 'is_array_buffer_or_view': is_array_buffer_or_view, | 184 'is_array_buffer_or_view': is_array_buffer_or_view, |
205 'is_check_security': is_check_security, | 185 'is_check_security': is_check_security, |
206 'is_event_target': is_event_target, | 186 'is_event_target': is_event_target, |
207 'is_exception': interface.is_exception, | 187 'is_exception': interface.is_exception, |
208 'is_node': inherits_interface(interface.name, 'Node'), | 188 'is_node': inherits_interface(interface.name, 'Node'), |
209 'is_partial': interface.is_partial, | 189 'is_partial': interface.is_partial, |
210 'is_typed_array_type': is_typed_array_type, | 190 'is_typed_array_type': is_typed_array_type, |
211 'iterator_method': iterator_method, | |
212 'lifetime': 'Dependent' | 191 'lifetime': 'Dependent' |
213 if (has_visit_dom_wrapper or | 192 if (has_visit_dom_wrapper or |
214 is_active_dom_object or | 193 is_active_dom_object or |
215 is_dependent_lifetime) | 194 is_dependent_lifetime) |
216 else 'Independent', | 195 else 'Independent', |
217 'measure_as': v8_utilities.measure_as(interface), # [MeasureAs] | 196 'measure_as': v8_utilities.measure_as(interface), # [MeasureAs] |
218 'parent_interface': parent_interface, | 197 'parent_interface': parent_interface, |
219 'pass_cpp_type': cpp_template_type( | 198 'pass_cpp_type': cpp_template_type( |
220 cpp_ptr_type('PassRefPtr', 'RawPtr', this_gc_type), | 199 cpp_ptr_type('PassRefPtr', 'RawPtr', this_gc_type), |
221 cpp_name(interface)), | 200 cpp_name(interface)), |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 for method in interface.operations | 315 for method in interface.operations |
337 if method.name]) # Skip anonymous special operations (metho
ds) | 316 if method.name]) # Skip anonymous special operations (metho
ds) |
338 if interface.partial_interfaces: | 317 if interface.partial_interfaces: |
339 assert len(interface.partial_interfaces) == len(set(interface.partial_in
terfaces)) | 318 assert len(interface.partial_interfaces) == len(set(interface.partial_in
terfaces)) |
340 for partial_interface in interface.partial_interfaces: | 319 for partial_interface in interface.partial_interfaces: |
341 methods.extend([v8_methods.method_context(interface, operation, is_v
isible=False) | 320 methods.extend([v8_methods.method_context(interface, operation, is_v
isible=False) |
342 for operation in partial_interface.operations | 321 for operation in partial_interface.operations |
343 if operation.name]) | 322 if operation.name]) |
344 compute_method_overloads_context(interface, methods) | 323 compute_method_overloads_context(interface, methods) |
345 | 324 |
| 325 def generated_method(return_type, name, arguments=None, extended_attributes=
None): |
| 326 operation = IdlOperation(interface.idl_name) |
| 327 operation.idl_type = return_type |
| 328 operation.name = name |
| 329 if arguments: |
| 330 operation.arguments = arguments |
| 331 if extended_attributes: |
| 332 operation.extended_attributes.update(extended_attributes) |
| 333 return v8_methods.method_context(interface, operation) |
| 334 |
| 335 # [Iterable], iterable<>, maplike<> and setlike<> |
| 336 iterator_method = None |
| 337 # FIXME: support Iterable in partial interfaces. However, we don't |
| 338 # need to support iterator overloads between interface and |
| 339 # partial interface definitions. |
| 340 # http://heycam.github.io/webidl/#idl-overloading |
| 341 if (not interface.is_partial |
| 342 and (interface.iterable or interface.maplike or interface.setlike |
| 343 or 'Iterable' in extended_attributes)): |
| 344 |
| 345 def generated_iterator_method(name): |
| 346 return generated_method( |
| 347 return_type=IdlType('Iterator'), |
| 348 name=name, |
| 349 extended_attributes={'RaisesException': None, 'CallWith': 'Scrip
tState'}) |
| 350 |
| 351 iterator_method = generated_iterator_method('iterator') |
| 352 |
| 353 if interface.iterable: |
| 354 methods.extend([ |
| 355 generated_iterator_method('keys'), |
| 356 generated_iterator_method('values'), |
| 357 generated_iterator_method('entries'), |
| 358 ]) |
| 359 |
| 360 # FIXME: maplike<> and setlike<> should also imply the presence of a |
| 361 # subset of keys(), values(), entries(), forEach(), has(), get(), add(), |
| 362 # set(), delete() and clear(), and a 'size' attribute. |
| 363 |
346 # Stringifier | 364 # Stringifier |
347 if interface.stringifier: | 365 if interface.stringifier: |
348 stringifier = interface.stringifier | 366 stringifier = interface.stringifier |
349 method = IdlOperation(interface.idl_name) | 367 stringifier_ext_attrs = stringifier.extended_attributes.copy() |
350 method.name = 'toString' | |
351 method.idl_type = IdlType('DOMString') | |
352 method.extended_attributes.update(stringifier.extended_attributes) | |
353 if stringifier.attribute: | 368 if stringifier.attribute: |
354 method.extended_attributes['ImplementedAs'] = stringifier.attribute.
name | 369 stringifier_ext_attrs['ImplementedAs'] = stringifier.attribute.name |
355 elif stringifier.operation: | 370 elif stringifier.operation: |
356 method.extended_attributes['ImplementedAs'] = stringifier.operation.
name | 371 stringifier_ext_attrs['ImplementedAs'] = stringifier.operation.name |
357 methods.append(v8_methods.method_context(interface, method)) | 372 methods.append(generated_method( |
| 373 return_type=IdlType('DOMString'), |
| 374 name='toString', |
| 375 extended_attributes=stringifier_ext_attrs)) |
358 | 376 |
359 conditionally_enabled_methods = [] | 377 conditionally_enabled_methods = [] |
360 custom_registration_methods = [] | 378 custom_registration_methods = [] |
361 method_configuration_methods = [] | 379 method_configuration_methods = [] |
362 | 380 |
363 for method in methods: | 381 for method in methods: |
364 # Skip all but one method in each set of overloaded methods. | 382 # Skip all but one method in each set of overloaded methods. |
365 if 'overload_index' in method and 'overloads' not in method: | 383 if 'overload_index' in method and 'overloads' not in method: |
366 continue | 384 continue |
367 | 385 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 method['number_of_required_arguments']) | 431 method['number_of_required_arguments']) |
414 | 432 |
415 context.update({ | 433 context.update({ |
416 'conditionally_enabled_methods': conditionally_enabled_methods, | 434 'conditionally_enabled_methods': conditionally_enabled_methods, |
417 'custom_registration_methods': custom_registration_methods, | 435 'custom_registration_methods': custom_registration_methods, |
418 'has_origin_safe_method_setter': any( | 436 'has_origin_safe_method_setter': any( |
419 method['is_check_security_for_frame'] and not method['is_read_only'] | 437 method['is_check_security_for_frame'] and not method['is_read_only'] |
420 for method in methods), | 438 for method in methods), |
421 'has_private_script': any(attribute['is_implemented_in_private_script']
for attribute in attributes) or | 439 'has_private_script': any(attribute['is_implemented_in_private_script']
for attribute in attributes) or |
422 any(method['is_implemented_in_private_script'] for method in methods
), | 440 any(method['is_implemented_in_private_script'] for method in methods
), |
| 441 'iterator_method': iterator_method, |
423 'method_configuration_methods': method_configuration_methods, | 442 'method_configuration_methods': method_configuration_methods, |
424 'methods': methods, | 443 'methods': methods, |
425 }) | 444 }) |
426 | 445 |
427 context.update({ | 446 context.update({ |
428 'indexed_property_getter': indexed_property_getter(interface), | 447 'indexed_property_getter': indexed_property_getter(interface), |
429 'indexed_property_setter': indexed_property_setter(interface), | 448 'indexed_property_setter': indexed_property_setter(interface), |
430 'indexed_property_deleter': indexed_property_deleter(interface), | 449 'indexed_property_deleter': indexed_property_deleter(interface), |
431 'is_override_builtins': 'OverrideBuiltins' in extended_attributes, | 450 'is_override_builtins': 'OverrideBuiltins' in extended_attributes, |
432 'named_property_getter': named_property_getter(interface), | 451 'named_property_getter': named_property_getter(interface), |
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1268 deleter = next( | 1287 deleter = next( |
1269 method | 1288 method |
1270 for method in interface.operations | 1289 for method in interface.operations |
1271 if ('deleter' in method.specials and | 1290 if ('deleter' in method.specials and |
1272 len(method.arguments) == 1 and | 1291 len(method.arguments) == 1 and |
1273 str(method.arguments[0].idl_type) == 'DOMString')) | 1292 str(method.arguments[0].idl_type) == 'DOMString')) |
1274 except StopIteration: | 1293 except StopIteration: |
1275 return None | 1294 return None |
1276 | 1295 |
1277 return property_deleter(deleter) | 1296 return property_deleter(deleter) |
OLD | NEW |