| 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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 effective_overloads_by_length = effective_overload_set_by_length(overloads) | 357 effective_overloads_by_length = effective_overload_set_by_length(overloads) |
| 358 lengths = [length for length, _ in effective_overloads_by_length] |
| 358 | 359 |
| 359 return { | 360 return { |
| 360 'deprecate_all_as': common_value(overloads, 'deprecate_as'), # [Depreca
teAs] | 361 'deprecate_all_as': common_value(overloads, 'deprecate_as'), # [Depreca
teAs] |
| 361 'length_tests_methods': length_tests_methods(effective_overloads_by_leng
th), | 362 'length_tests_methods': length_tests_methods(effective_overloads_by_leng
th), |
| 363 'minarg': lengths[0], |
| 362 # 1. Let maxarg be the length of the longest type list of the | 364 # 1. Let maxarg be the length of the longest type list of the |
| 363 # entries in S. | 365 # entries in S. |
| 364 'maxarg': max(i for i, _ in effective_overloads_by_length), | 366 'maxarg': lengths[-1], |
| 365 'measure_all_as': common_value(overloads, 'measure_as'), # [MeasureAs] | 367 'measure_all_as': common_value(overloads, 'measure_as'), # [MeasureAs] |
| 366 'minimum_number_of_required_arguments': | 368 'valid_arities': lengths |
| 367 min(method['number_of_required_arguments'] for method in overloads), | 369 # Only need to report valid arities if there is a gap in the |
| 370 # sequence of possible lengths, otherwise invalid length means |
| 371 # "not enough arguments". |
| 372 if lengths[-1] - lengths[0] != len(lengths) - 1 else None, |
| 368 } | 373 } |
| 369 | 374 |
| 370 | 375 |
| 371 def effective_overload_set(F): | 376 def effective_overload_set(F): |
| 372 """Returns the effective overload set of an overloaded function. | 377 """Returns the effective overload set of an overloaded function. |
| 373 | 378 |
| 374 An effective overload set is the set of overloaded functions + signatures | 379 An effective overload set is the set of overloaded functions + signatures |
| 375 (type list of arguments, with optional and variadic arguments included or | 380 (type list of arguments, with optional and variadic arguments included or |
| 376 not), and is used in the overload resolution algorithm. | 381 not), and is used in the overload resolution algorithm. |
| 377 | 382 |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 deleter = next( | 1003 deleter = next( |
| 999 method | 1004 method |
| 1000 for method in interface.operations | 1005 for method in interface.operations |
| 1001 if ('deleter' in method.specials and | 1006 if ('deleter' in method.specials and |
| 1002 len(method.arguments) == 1 and | 1007 len(method.arguments) == 1 and |
| 1003 str(method.arguments[0].idl_type) == 'DOMString')) | 1008 str(method.arguments[0].idl_type) == 'DOMString')) |
| 1004 except StopIteration: | 1009 except StopIteration: |
| 1005 return None | 1010 return None |
| 1006 | 1011 |
| 1007 return property_deleter(deleter) | 1012 return property_deleter(deleter) |
| OLD | NEW |