Index: Source/bindings/scripts/v8_interface.py |
diff --git a/Source/bindings/scripts/v8_interface.py b/Source/bindings/scripts/v8_interface.py |
index fdefb37d21ec2589a1314edd5f6a4452be179fd1..38b186e7d0150d0747651e9f9baab04459146630 100644 |
--- a/Source/bindings/scripts/v8_interface.py |
+++ b/Source/bindings/scripts/v8_interface.py |
@@ -257,6 +257,17 @@ def generate_interface(interface): |
# For overloaded methods, only generate one accessor |
('overload_index' not in method or method['overload_index'] == 1)) |
+ # The value of the Function object’s “length” property is a Number |
+ # determined as follows: |
+ # 1. Let S be the effective overload set for regular operations (if the |
+ # operation is a regular operation) or for static operations (if the |
+ # operation is a static operation) with identifier id on interface I and |
+ # with argument count 0. |
+ # 2. Return the length of the shortest argument list of the entries in S. |
+ # FIXME: This calculation doesn't take into account whether runtime |
+ # enabled overloads are actually enabled. |
Nils Barth (inactive)
2014/06/05 00:26:22
Could you elaborate slightly, giving an example?
E
|
+ method['length'] = method['overloads']['minarg'] if 'overloads' in method else method['number_of_required_arguments'] |
Nils Barth (inactive)
2014/06/05 00:26:22
Could you wrap this line?
|
+ |
template_contents.update({ |
'has_origin_safe_method_setter': any( |
method['is_check_security_for_frame'] and not method['is_read_only'] |
@@ -357,6 +368,16 @@ def generate_overloads(overloads): |
effective_overloads_by_length = effective_overload_set_by_length(overloads) |
lengths = [length for length, _ in effective_overloads_by_length] |
+ # Check and fail if all overloads with the shortest acceptable arguments |
Nils Barth (inactive)
2014/06/05 00:26:22
Thanks, this is a great explanation!
|
+ # list are runtime enabled, since we would otherwise set 'length' on the |
+ # function object to an incorrect value when none of those overloads were |
+ # actually enabled at runtime. The exception is if all overloads are |
+ # controlled by the same runtime enabled feature, in which case there would |
+ # be no function object at all if it is not enabled. |
+ if (not common_value(overloads, 'runtime_enabled_function') and |
+ all(method.get('runtime_enabled_function') for method, _, _ in effective_overloads_by_length[0][1])): |
Nils Barth (inactive)
2014/06/05 00:26:22
Style points:
* Could you wrap this line?
* Could
|
+ raise ValueError('Function.length of %s depends on runtime enabled features' % overloads[0]['name']) |
+ |
return { |
'deprecate_all_as': common_value(overloads, 'deprecate_as'), # [DeprecateAs] |
'length_tests_methods': length_tests_methods(effective_overloads_by_length), |