| 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 base_idl_type in ['EventTarget', 'Window'] or | 371 base_idl_type in ['EventTarget', 'Window'] or |
| 372 base_idl_type.startswith(('HTML', 'SVG'))))) | 372 base_idl_type.startswith(('HTML', 'SVG'))))) |
| 373 | 373 |
| 374 | 374 |
| 375 ################################################################################ | 375 ################################################################################ |
| 376 # Setter | 376 # Setter |
| 377 ################################################################################ | 377 ################################################################################ |
| 378 | 378 |
| 379 def setter_context(interface, attribute, interfaces, context): | 379 def setter_context(interface, attribute, interfaces, context): |
| 380 if 'PutForwards' in attribute.extended_attributes: | 380 if 'PutForwards' in attribute.extended_attributes: |
| 381 # Use target interface and attribute in place of original interface and | 381 # Make sure the target interface and attribute exist. |
| 382 # attribute from this point onwards. | |
| 383 target_interface_name = attribute.idl_type.base_type | 382 target_interface_name = attribute.idl_type.base_type |
| 384 target_attribute_name = attribute.extended_attributes['PutForwards'] | 383 target_attribute_name = attribute.extended_attributes['PutForwards'] |
| 385 interface = interfaces[target_interface_name] | 384 interface = interfaces[target_interface_name] |
| 386 try: | 385 try: |
| 387 attribute = next(candidate | 386 next(candidate |
| 388 for candidate in interface.attributes | 387 for candidate in interface.attributes |
| 389 if candidate.name == target_attribute_name) | 388 if candidate.name == target_attribute_name) |
| 390 except StopIteration: | 389 except StopIteration: |
| 391 raise Exception('[PutForward] target not found:\n' | 390 raise Exception('[PutForward] target not found:\n' |
| 392 'Attribute "%s" is not present in interface "%s"' % | 391 'Attribute "%s" is not present in interface "%s"' % |
| 393 (target_attribute_name, target_interface_name)) | 392 (target_attribute_name, target_interface_name)) |
| 393 context['target_attribute_name'] = target_attribute_name |
| 394 return |
| 394 | 395 |
| 395 if ('Replaceable' in attribute.extended_attributes): | 396 if ('Replaceable' in attribute.extended_attributes): |
| 396 context['cpp_setter'] = 'v8CallBoolean(info.Holder()->CreateDataProperty
(info.GetIsolate()->GetCurrentContext(), propertyName, v8Value))' | 397 context['cpp_setter'] = 'v8CallBoolean(info.Holder()->CreateDataProperty
(info.GetIsolate()->GetCurrentContext(), propertyName, v8Value))' |
| 397 return | 398 return |
| 398 | 399 |
| 399 extended_attributes = attribute.extended_attributes | 400 extended_attributes = attribute.extended_attributes |
| 400 idl_type = attribute.idl_type | 401 idl_type = attribute.idl_type |
| 401 | 402 |
| 402 # [RaisesException], [RaisesException=Setter] | 403 # [RaisesException], [RaisesException=Setter] |
| 403 is_setter_raises_exception = ( | 404 is_setter_raises_exception = ( |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 lambda self: strip_suffix(self.base_type, 'Constructor')) | 558 lambda self: strip_suffix(self.base_type, 'Constructor')) |
| 558 | 559 |
| 559 | 560 |
| 560 def is_constructor_attribute(attribute): | 561 def is_constructor_attribute(attribute): |
| 561 # FIXME: replace this with [ConstructorAttribute] extended attribute | 562 # FIXME: replace this with [ConstructorAttribute] extended attribute |
| 562 return attribute.idl_type.name.endswith('Constructor') | 563 return attribute.idl_type.name.endswith('Constructor') |
| 563 | 564 |
| 564 | 565 |
| 565 def update_constructor_attribute_context(interface, attribute, context): | 566 def update_constructor_attribute_context(interface, attribute, context): |
| 566 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] | 567 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] |
| OLD | NEW |