| 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 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 'is_raises_exception': is_raises_exception, | 619 'is_raises_exception': is_raises_exception, |
| 620 'name': DartUtilities.cpp_name(getter), | 620 'name': DartUtilities.cpp_name(getter), |
| 621 'union_arguments': union_arguments, | 621 'union_arguments': union_arguments, |
| 622 'dart_set_return_value': idl_type.dart_set_return_value('result', | 622 'dart_set_return_value': idl_type.dart_set_return_value('result', |
| 623 extended_attribu
tes=extended_attributes, | 623 extended_attribu
tes=extended_attributes, |
| 624 script_wrappable
='receiver', | 624 script_wrappable
='receiver', |
| 625 release=idl_type
.release)}) | 625 release=idl_type
.release)}) |
| 626 return context | 626 return context |
| 627 | 627 |
| 628 | 628 |
| 629 def property_setter(setter): | 629 def property_setter(setter, cpp_arguments): |
| 630 context = v8_interface.property_setter(setter) | 630 context = v8_interface.property_setter(setter) |
| 631 | 631 |
| 632 idl_type = setter.arguments[1].idl_type | 632 idl_type = setter.idl_type |
| 633 extended_attributes = setter.extended_attributes | 633 extended_attributes = setter.extended_attributes |
| 634 is_raises_exception = 'RaisesException' in extended_attributes |
| 634 | 635 |
| 636 cpp_method_name = 'receiver->%s' % DartUtilities.cpp_name(setter) |
| 637 |
| 638 if is_raises_exception: |
| 639 cpp_arguments.append('es') |
| 640 |
| 641 cpp_value = '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments)) |
| 635 context.update({ | 642 context.update({ |
| 636 'dart_value_to_local_cpp_value': idl_type.dart_value_to_local_cpp_value( | 643 'cpp_type': idl_type.cpp_type, |
| 637 extended_attributes, 'propertyValue', False, | 644 'cpp_value': cpp_value, |
| 638 context['has_type_checking_interface']), | 645 'is_raises_exception': is_raises_exception, |
| 639 }) | 646 'name': DartUtilities.cpp_name(setter)}) |
| 640 | |
| 641 return context | 647 return context |
| 642 | 648 |
| 643 | 649 |
| 644 ################################################################################ | 650 ################################################################################ |
| 645 # Indexed properties | 651 # Indexed properties |
| 646 # http://heycam.github.io/webidl/#idl-indexed-properties | 652 # http://heycam.github.io/webidl/#idl-indexed-properties |
| 647 ################################################################################ | 653 ################################################################################ |
| 648 | 654 |
| 649 def indexed_property_getter(interface): | 655 def indexed_property_getter(interface): |
| 650 try: | 656 try: |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 method | 699 method |
| 694 for method in interface.operations | 700 for method in interface.operations |
| 695 if ('getter' in method.specials and | 701 if ('getter' in method.specials and |
| 696 len(method.arguments) == 1 and | 702 len(method.arguments) == 1 and |
| 697 str(method.arguments[0].idl_type) == 'DOMString')) | 703 str(method.arguments[0].idl_type) == 'DOMString')) |
| 698 except StopIteration: | 704 except StopIteration: |
| 699 return None | 705 return None |
| 700 | 706 |
| 701 getter.name = getter.name or 'anonymousNamedGetter' | 707 getter.name = getter.name or 'anonymousNamedGetter' |
| 702 | 708 |
| 703 return property_getter(getter, ['propertyName']) | 709 return property_getter(getter, [getter.arguments[0].name]) |
| 704 | 710 |
| 705 | 711 |
| 706 def named_property_setter(interface): | 712 def named_property_setter(interface): |
| 707 try: | 713 try: |
| 708 # Find named property setter, if present; has form: | 714 # Find named property setter, if present; has form: |
| 709 # setter RETURN_TYPE [OPTIONAL_IDENTIFIER](DOMString ARG1, ARG_TYPE ARG2
) | 715 # setter RETURN_TYPE [OPTIONAL_IDENTIFIER](DOMString ARG1, ARG_TYPE ARG2
) |
| 710 setter = next( | 716 setter = next( |
| 711 method | 717 method |
| 712 for method in interface.operations | 718 for method in interface.operations |
| 713 if ('setter' in method.specials and | 719 if ('setter' in method.specials and |
| 714 len(method.arguments) == 2 and | 720 len(method.arguments) == 2 and |
| 715 str(method.arguments[0].idl_type) == 'DOMString')) | 721 str(method.arguments[0].idl_type) == 'DOMString')) |
| 716 except StopIteration: | 722 except StopIteration: |
| 717 return None | 723 return None |
| 718 | 724 |
| 719 return property_setter(setter) | 725 return property_setter(setter, [setter.arguments[0].name, |
| 726 setter.arguments[1].name]) |
| 720 | 727 |
| 721 | 728 |
| 722 def generate_native_entries_for_specials(interface, context): | 729 def generate_native_entries_for_specials(interface, context): |
| 723 def add(prop, name, arity): | 730 def add(prop, name, arity): |
| 724 if context[prop]: | 731 if context[prop]: |
| 725 if 'native_entries' not in context[prop]: | 732 if 'native_entries' not in context[prop]: |
| 726 context[prop].update({'native_entries': []}) | 733 context[prop].update({'native_entries': []}) |
| 727 context[prop]['native_entries'].append( | 734 context[prop]['native_entries'].append( |
| 728 DartUtilities.generate_native_entry( | 735 DartUtilities.generate_native_entry( |
| 729 interface.name, name, 'Method', False, arity)) | 736 interface.name, name, 'Method', False, arity)) |
| 730 | 737 |
| 731 pre = ['indexed_property', 'named_property'] | 738 pre = ['indexed_property', 'named_property'] |
| 732 post = [('setter', '__setter__', 2), | 739 post = [('setter', '__setter__', 2), |
| 733 ('getter', '__getter__', 1), | 740 ('getter', '__getter__', 1), |
| 734 ('deleter', '__delete__', 1), | 741 ('deleter', '__delete__', 1), |
| 735 ] | 742 ] |
| 736 props = [(p1 + "_" + p2, name, arity) | 743 props = [(p1 + "_" + p2, name, arity) |
| 737 for (p1, (p2, name, arity)) in itertools.product(pre, post)] | 744 for (p1, (p2, name, arity)) in itertools.product(pre, post)] |
| 738 for t in props: | 745 for t in props: |
| 739 add(*t) | 746 add(*t) |
| 740 | 747 |
| 741 for (p, name, arity) in props: | 748 for (p, name, arity) in props: |
| 742 if context[p]: | 749 if context[p]: |
| 743 if context[p].get('is_custom_property_query'): | 750 if context[p].get('is_custom_property_query'): |
| 744 add(p, '__propertyQuery__', 1) | 751 add(p, '__propertyQuery__', 1) |
| OLD | NEW |