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 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 # • a numeric type | 746 # • a numeric type |
747 try: | 747 try: |
748 method = next(method for idl_type, method in idl_types_methods | 748 method = next(method for idl_type, method in idl_types_methods |
749 if idl_type.is_numeric_type) | 749 if idl_type.is_numeric_type) |
750 test = '%s->IsNumber()' % cpp_value | 750 test = '%s->IsNumber()' % cpp_value |
751 yield test, method | 751 yield test, method |
752 except StopIteration: | 752 except StopIteration: |
753 pass | 753 pass |
754 | 754 |
755 # (Perform automatic type conversion, in order. If any of these match, | 755 # (Perform automatic type conversion, in order. If any of these match, |
756 # that’s the end, and no other tests are needed.) | 756 # that’s the end, and no other tests are needed.) To keep this code simple, |
| 757 # we rely on the C++ compiler's dead code elimination to deal with the |
| 758 # redundancy if both cases below trigger. |
757 | 759 |
758 # 11. Otherwise: if there is an entry in S that has one of the following | 760 # 11. Otherwise: if there is an entry in S that has one of the following |
759 # types at position i of its type list, | 761 # types at position i of its type list, |
760 # • DOMString | 762 # • DOMString |
761 # • an enumeration type | 763 # • an enumeration type |
762 try: | 764 try: |
763 method = next(method for idl_type, method in idl_types_methods | 765 method = next(method for idl_type, method in idl_types_methods |
764 if idl_type.name == 'String' or idl_type.is_enum) | 766 if idl_type.name == 'String' or idl_type.is_enum) |
765 yield 'true', method | 767 yield 'true', method |
766 return | |
767 except StopIteration: | 768 except StopIteration: |
768 pass | 769 pass |
769 | 770 |
770 # 12. Otherwise: if there is an entry in S that has one of the following | 771 # 12. Otherwise: if there is an entry in S that has one of the following |
771 # types at position i of its type list, | 772 # types at position i of its type list, |
772 # • a numeric type | 773 # • a numeric type |
773 try: | 774 try: |
774 method = next(method for idl_type, method in idl_types_methods | 775 method = next(method for idl_type, method in idl_types_methods |
775 if idl_type.is_numeric_type) | 776 if idl_type.is_numeric_type) |
776 yield 'true', method | 777 yield 'true', method |
777 return | |
778 except StopIteration: | 778 except StopIteration: |
779 pass | 779 pass |
780 | 780 |
781 | 781 |
782 ################################################################################ | 782 ################################################################################ |
783 # Utility functions | 783 # Utility functions |
784 ################################################################################ | 784 ################################################################################ |
785 | 785 |
786 def Counter(iterable): | 786 def Counter(iterable): |
787 # Once using Python 2.7, using collections.Counter | 787 # Once using Python 2.7, using collections.Counter |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 deleter = next( | 1090 deleter = next( |
1091 method | 1091 method |
1092 for method in interface.operations | 1092 for method in interface.operations |
1093 if ('deleter' in method.specials and | 1093 if ('deleter' in method.specials and |
1094 len(method.arguments) == 1 and | 1094 len(method.arguments) == 1 and |
1095 str(method.arguments[0].idl_type) == 'DOMString')) | 1095 str(method.arguments[0].idl_type) == 'DOMString')) |
1096 except StopIteration: | 1096 except StopIteration: |
1097 return None | 1097 return None |
1098 | 1098 |
1099 return property_deleter(deleter) | 1099 return property_deleter(deleter) |
OLD | NEW |