| 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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 if 'overloads' in method: | 362 if 'overloads' in method: |
| 363 overloads = method['overloads'] | 363 overloads = method['overloads'] |
| 364 if not overloads['visible']: | 364 if not overloads['visible']: |
| 365 continue | 365 continue |
| 366 # original interface will register instead of partial interface. | 366 # original interface will register instead of partial interface. |
| 367 if overloads['has_partial_overloads'] and interface.is_partial: | 367 if overloads['has_partial_overloads'] and interface.is_partial: |
| 368 continue | 368 continue |
| 369 per_context_enabled_function = overloads['per_context_enabled_functi
on_all'] | 369 per_context_enabled_function = overloads['per_context_enabled_functi
on_all'] |
| 370 conditionally_exposed_function = overloads['exposed_test_all'] | 370 conditionally_exposed_function = overloads['exposed_test_all'] |
| 371 runtime_enabled_function = overloads['runtime_enabled_function_all'] | 371 runtime_enabled_function = overloads['runtime_enabled_function_all'] |
| 372 has_custom_registration = overloads['has_custom_registration_all'] | 372 has_custom_registration = (overloads['has_custom_registration_all']
or |
| 373 overloads['runtime_determined_lengths']) |
| 373 else: | 374 else: |
| 374 if not method['visible']: | 375 if not method['visible']: |
| 375 continue | 376 continue |
| 376 per_context_enabled_function = method['per_context_enabled_function'
] | 377 per_context_enabled_function = method['per_context_enabled_function'
] |
| 377 conditionally_exposed_function = method['exposed_test'] | 378 conditionally_exposed_function = method['exposed_test'] |
| 378 runtime_enabled_function = method['runtime_enabled_function'] | 379 runtime_enabled_function = method['runtime_enabled_function'] |
| 379 has_custom_registration = method['has_custom_registration'] | 380 has_custom_registration = method['has_custom_registration'] |
| 380 | 381 |
| 381 if per_context_enabled_function or conditionally_exposed_function: | 382 if per_context_enabled_function or conditionally_exposed_function: |
| 382 conditionally_enabled_methods.append(method) | 383 conditionally_enabled_methods.append(method) |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 and returns dict of overall overload template values. | 496 and returns dict of overall overload template values. |
| 496 """ | 497 """ |
| 497 assert len(overloads) > 1 # only apply to overloaded names | 498 assert len(overloads) > 1 # only apply to overloaded names |
| 498 for index, method in enumerate(overloads, 1): | 499 for index, method in enumerate(overloads, 1): |
| 499 method['overload_index'] = index | 500 method['overload_index'] = index |
| 500 | 501 |
| 501 effective_overloads_by_length = effective_overload_set_by_length(overloads) | 502 effective_overloads_by_length = effective_overload_set_by_length(overloads) |
| 502 lengths = [length for length, _ in effective_overloads_by_length] | 503 lengths = [length for length, _ in effective_overloads_by_length] |
| 503 name = overloads[0].get('name', '<constructor>') | 504 name = overloads[0].get('name', '<constructor>') |
| 504 | 505 |
| 505 # Check and fail if all overloads with the shortest acceptable arguments | 506 # Check if all overloads with the shortest acceptable arguments list are |
| 506 # list are runtime enabled, since we would otherwise set 'length' on the | 507 # runtime enabled, in which case we need to have a runtime determined |
| 507 # function object to an incorrect value when none of those overloads were | 508 # Function.length. The exception is if all overloads are controlled by the |
| 508 # actually enabled at runtime. The exception is if all overloads are | 509 # same runtime enabled feature, in which case there would be no function |
| 509 # controlled by the same runtime enabled feature, in which case there would | 510 # object at all if it is not enabled. |
| 510 # be no function object at all if it is not enabled. | |
| 511 shortest_overloads = effective_overloads_by_length[0][1] | 511 shortest_overloads = effective_overloads_by_length[0][1] |
| 512 if (all(method.get('runtime_enabled_function') | 512 if (all(method.get('runtime_enabled_function') |
| 513 for method, _, _ in shortest_overloads) and | 513 for method, _, _ in shortest_overloads) and |
| 514 not common_value(overloads, 'runtime_enabled_function')): | 514 not common_value(overloads, 'runtime_enabled_function')): |
| 515 raise ValueError('Function.length of %s depends on runtime enabled featu
res' % name) | 515 # Generate a list of (length, runtime_enabled_functions) tuples. |
| 516 runtime_determined_lengths = [] |
| 517 for length, effective_overloads in effective_overloads_by_length: |
| 518 runtime_enabled_functions = set( |
| 519 method['runtime_enabled_function'] |
| 520 for method, _, _ in effective_overloads |
| 521 if method.get('runtime_enabled_function')) |
| 522 if not runtime_enabled_functions: |
| 523 # This "length" is unconditionally enabled, so stop here. |
| 524 runtime_determined_lengths.append((length, [None])) |
| 525 break |
| 526 runtime_determined_lengths.append( |
| 527 (length, sorted(runtime_enabled_functions))) |
| 528 length = ('%sV8Internal::%sMethodLength()' |
| 529 % (cpp_name_or_partial(interface), name)) |
| 530 else: |
| 531 runtime_determined_lengths = None |
| 532 length = lengths[0] |
| 516 | 533 |
| 517 # Check and fail if overloads disagree on any of the extended attributes | 534 # Check and fail if overloads disagree on any of the extended attributes |
| 518 # that affect how the method should be registered. | 535 # that affect how the method should be registered. |
| 519 # Skip the check for overloaded constructors, since they don't support any | 536 # Skip the check for overloaded constructors, since they don't support any |
| 520 # of the extended attributes in question. | 537 # of the extended attributes in question. |
| 521 if not overloads[0].get('is_constructor'): | 538 if not overloads[0].get('is_constructor'): |
| 522 overload_extended_attributes = [ | 539 overload_extended_attributes = [ |
| 523 method['custom_registration_extended_attributes'] | 540 method['custom_registration_extended_attributes'] |
| 524 for method in overloads] | 541 for method in overloads] |
| 525 for extended_attribute in v8_methods.CUSTOM_REGISTRATION_EXTENDED_ATTRIB
UTES: | 542 for extended_attribute in v8_methods.CUSTOM_REGISTRATION_EXTENDED_ATTRIB
UTES: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 545 has_overload_not_visible = True | 562 has_overload_not_visible = True |
| 546 | 563 |
| 547 # If some overloads are not visible and others are visible, | 564 # If some overloads are not visible and others are visible, |
| 548 # the method is overloaded between core and modules. | 565 # the method is overloaded between core and modules. |
| 549 has_partial_overloads = has_overload_visible and has_overload_not_visible | 566 has_partial_overloads = has_overload_visible and has_overload_not_visible |
| 550 | 567 |
| 551 return { | 568 return { |
| 552 'deprecate_all_as': common_value(overloads, 'deprecate_as'), # [Depreca
teAs] | 569 'deprecate_all_as': common_value(overloads, 'deprecate_as'), # [Depreca
teAs] |
| 553 'exposed_test_all': common_value(overloads, 'exposed_test'), # [Exposed
] | 570 'exposed_test_all': common_value(overloads, 'exposed_test'), # [Exposed
] |
| 554 'has_custom_registration_all': common_value(overloads, 'has_custom_regis
tration'), | 571 'has_custom_registration_all': common_value(overloads, 'has_custom_regis
tration'), |
| 572 'length': length, |
| 555 'length_tests_methods': length_tests_methods(effective_overloads_by_leng
th), | 573 'length_tests_methods': length_tests_methods(effective_overloads_by_leng
th), |
| 556 # 1. Let maxarg be the length of the longest type list of the | 574 # 1. Let maxarg be the length of the longest type list of the |
| 557 # entries in S. | 575 # entries in S. |
| 558 'maxarg': lengths[-1], | 576 'maxarg': lengths[-1], |
| 559 'measure_all_as': common_value(overloads, 'measure_as'), # [MeasureAs] | 577 'measure_all_as': common_value(overloads, 'measure_as'), # [MeasureAs] |
| 560 'minarg': lengths[0], | 578 'minarg': lengths[0], |
| 561 'per_context_enabled_function_all': common_value(overloads, 'per_context
_enabled_function'), # [PerContextEnabled] | 579 'per_context_enabled_function_all': common_value(overloads, 'per_context
_enabled_function'), # [PerContextEnabled] |
| 562 'returns_promise_all': promise_overload_count > 0, | 580 'returns_promise_all': promise_overload_count > 0, |
| 581 'runtime_determined_lengths': runtime_determined_lengths, |
| 563 'runtime_enabled_function_all': common_value(overloads, 'runtime_enabled
_function'), # [RuntimeEnabled] | 582 'runtime_enabled_function_all': common_value(overloads, 'runtime_enabled
_function'), # [RuntimeEnabled] |
| 564 'valid_arities': lengths | 583 'valid_arities': lengths |
| 565 # Only need to report valid arities if there is a gap in the | 584 # Only need to report valid arities if there is a gap in the |
| 566 # sequence of possible lengths, otherwise invalid length means | 585 # sequence of possible lengths, otherwise invalid length means |
| 567 # "not enough arguments". | 586 # "not enough arguments". |
| 568 if lengths[-1] - lengths[0] != len(lengths) - 1 else None, | 587 if lengths[-1] - lengths[0] != len(lengths) - 1 else None, |
| 569 'visible': has_overload_visible, | 588 'visible': has_overload_visible, |
| 570 'has_partial_overloads': has_partial_overloads, | 589 'has_partial_overloads': has_partial_overloads, |
| 571 } | 590 } |
| 572 | 591 |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1236 deleter = next( | 1255 deleter = next( |
| 1237 method | 1256 method |
| 1238 for method in interface.operations | 1257 for method in interface.operations |
| 1239 if ('deleter' in method.specials and | 1258 if ('deleter' in method.specials and |
| 1240 len(method.arguments) == 1 and | 1259 len(method.arguments) == 1 and |
| 1241 str(method.arguments[0].idl_type) == 'DOMString')) | 1260 str(method.arguments[0].idl_type) == 'DOMString')) |
| 1242 except StopIteration: | 1261 except StopIteration: |
| 1243 return None | 1262 return None |
| 1244 | 1263 |
| 1245 return property_deleter(deleter) | 1264 return property_deleter(deleter) |
| OLD | NEW |