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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
347 def generate_overloads(overloads): | 347 def generate_overloads(overloads): |
348 """Returns |overloads| template values for a single name. | 348 """Returns |overloads| template values for a single name. |
349 | 349 |
350 Sets |method.overload_index| in place for |method| in |overloads| | 350 Sets |method.overload_index| in place for |method| in |overloads| |
351 and returns dict of overall overload template values. | 351 and returns dict of overall overload template values. |
352 """ | 352 """ |
353 assert len(overloads) > 1 # only apply to overloaded names | 353 assert len(overloads) > 1 # only apply to overloaded names |
354 for index, method in enumerate(overloads, 1): | 354 for index, method in enumerate(overloads, 1): |
355 method['overload_index'] = index | 355 method['overload_index'] = index |
356 | 356 |
357 runtime_enabled_features = set(method.get('runtime_enabled_function') | |
Nils Barth (inactive)
2014/05/27 06:33:20
You don't need dict.get() here, do you?
Jens Widell
2014/05/27 06:46:20
Needed for overloaded constructors currently; gene
Nils Barth (inactive)
2014/05/27 07:24:17
Oh, good point.
get() is a bit better, since havin
| |
358 for method in overloads) | |
359 if len(runtime_enabled_features) > 1: | |
Nils Barth (inactive)
2014/05/27 06:33:20
Shouldn't you use the utility common_value() funct
Jens Widell
2014/05/27 06:46:20
It returns None both if there is no common value a
Nils Barth (inactive)
2014/05/27 07:24:17
Oh, good point.
I'd prefer consistency with the o
Jens Widell
2014/05/27 07:39:17
That works nicely in the overload_resolution_metho
Jens Widell
2014/05/27 07:42:15
But that of course doesn't work for non-overloaded
Nils Barth (inactive)
2014/05/27 07:50:42
That sounds great!
Nils Barth (inactive)
2014/05/27 07:50:42
...why not? (confused)
| |
360 # More than one different value for [RuntimeEnabled] among the | |
Nils Barth (inactive)
2014/05/27 06:33:20
Could you clarify that this also works for *missin
Jens Widell
2014/05/27 06:46:20
Yeah, I'm essentially treating None as any other v
Nils Barth (inactive)
2014/05/27 07:24:17
None is confusing enough that I'd appreciate a com
| |
361 # overloads; need to handle as part of overload resoultion. | |
362 for method in overloads: | |
363 method['overload_runtime_enabled_function'] = method['runtime_enable d_function'] | |
364 method['runtime_enabled_function'] = None | |
365 | |
357 effective_overloads_by_length = effective_overload_set_by_length(overloads) | 366 effective_overloads_by_length = effective_overload_set_by_length(overloads) |
358 lengths = [length for length, _ in effective_overloads_by_length] | 367 lengths = [length for length, _ in effective_overloads_by_length] |
359 | 368 |
360 return { | 369 return { |
361 'deprecate_all_as': common_value(overloads, 'deprecate_as'), # [Depreca teAs] | 370 'deprecate_all_as': common_value(overloads, 'deprecate_as'), # [Depreca teAs] |
362 'length_tests_methods': length_tests_methods(effective_overloads_by_leng th), | 371 'length_tests_methods': length_tests_methods(effective_overloads_by_leng th), |
363 'minarg': lengths[0], | 372 'minarg': lengths[0], |
364 # 1. Let maxarg be the length of the longest type list of the | 373 # 1. Let maxarg be the length of the longest type list of the |
365 # entries in S. | 374 # entries in S. |
366 'maxarg': lengths[-1], | 375 'maxarg': lengths[-1], |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
690 # that’s the end, and no other tests are needed.) | 699 # that’s the end, and no other tests are needed.) |
691 | 700 |
692 # 11. Otherwise: if there is an entry in S that has one of the following | 701 # 11. Otherwise: if there is an entry in S that has one of the following |
693 # types at position i of its type list, | 702 # types at position i of its type list, |
694 # • DOMString | 703 # • DOMString |
695 # • an enumeration type | 704 # • an enumeration type |
696 try: | 705 try: |
697 method = next(method for idl_type, method in idl_types_methods | 706 method = next(method for idl_type, method in idl_types_methods |
698 if idl_type.name == 'String' or idl_type.is_enum) | 707 if idl_type.name == 'String' or idl_type.is_enum) |
699 yield 'true', method | 708 yield 'true', method |
700 return | 709 # Stop here unless this overload (and not all overloads) is runtime |
Jens Widell
2014/05/23 14:55:16
A simpler fix here would of course be to just remo
Nils Barth (inactive)
2014/05/27 06:33:20
That's fine to do: CG simplicity is a higher prior
| |
710 # enabled. | |
711 if not method.get('overload_runtime_enabled_function'): | |
712 return | |
701 except StopIteration: | 713 except StopIteration: |
702 pass | 714 pass |
703 | 715 |
704 # 12. Otherwise: if there is an entry in S that has one of the following | 716 # 12. Otherwise: if there is an entry in S that has one of the following |
705 # types at position i of its type list, | 717 # types at position i of its type list, |
706 # • a numeric type | 718 # • a numeric type |
707 try: | 719 try: |
708 method = next(method for idl_type, method in idl_types_methods | 720 method = next(method for idl_type, method in idl_types_methods |
709 if idl_type.is_numeric_type) | 721 if idl_type.is_numeric_type) |
710 yield 'true', method | 722 yield 'true', method |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1007 deleter = next( | 1019 deleter = next( |
1008 method | 1020 method |
1009 for method in interface.operations | 1021 for method in interface.operations |
1010 if ('deleter' in method.specials and | 1022 if ('deleter' in method.specials and |
1011 len(method.arguments) == 1 and | 1023 len(method.arguments) == 1 and |
1012 str(method.arguments[0].idl_type) == 'DOMString')) | 1024 str(method.arguments[0].idl_type) == 'DOMString')) |
1013 except StopIteration: | 1025 except StopIteration: |
1014 return None | 1026 return None |
1015 | 1027 |
1016 return property_deleter(deleter) | 1028 return property_deleter(deleter) |
OLD | NEW |