Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Unified Diff: Source/bindings/scripts/v8_interface.py

Issue 328663003: IDL: restructure logic handling registration of methods (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: s/needs_/has_/ + check for conflicting ext attrs Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/bindings/scripts/v8_methods.py » ('j') | Source/bindings/scripts/v8_methods.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/v8_interface.py
diff --git a/Source/bindings/scripts/v8_interface.py b/Source/bindings/scripts/v8_interface.py
index db90d4c09eb55a64bbd26bdd3f54021a24b4685f..edd81c6ee1e54971f8070fbb7ee7fefe7d14bdaa 100644
--- a/Source/bindings/scripts/v8_interface.py
+++ b/Source/bindings/scripts/v8_interface.py
@@ -250,13 +250,35 @@ def generate_interface(interface):
for method in interface.operations
if method.name] # Skip anonymous special operations (methods)
generate_method_overloads(methods)
+
+ per_context_enabled_methods = []
+ custom_registration_methods = []
+ method_configuration_methods = []
+
for method in methods:
- method['do_generate_method_configuration'] = (
- method['do_not_check_signature'] and
- not method['per_context_enabled_function'] and
- # For overloaded methods, only generate one accessor
- ('overload_index' not in method or method['overload_index'] == 1))
+ # Skip all but one method in each set of overloaded methods.
+ if 'overload_index' in method and 'overloads' not in method:
+ continue
+
+ if 'overloads' in method:
+ overloads = method['overloads']
+ per_context_enabled_function = overloads['per_context_enabled_function_all']
+ runtime_enabled_function = overloads['runtime_enabled_function_all']
+ has_custom_registration = overloads['has_custom_registration_all']
+ else:
+ per_context_enabled_function = method['per_context_enabled_function']
+ runtime_enabled_function = method['runtime_enabled_function']
+ has_custom_registration = method['has_custom_registration']
+
+ if per_context_enabled_function:
+ per_context_enabled_methods.append(method)
+ continue
+ if runtime_enabled_function or has_custom_registration:
+ custom_registration_methods.append(method)
+ continue
+ method_configuration_methods.append(method)
+ for method in methods:
# 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
@@ -272,11 +294,12 @@ def generate_interface(interface):
method['number_of_required_arguments'])
template_contents.update({
+ 'custom_registration_methods': custom_registration_methods,
'has_origin_safe_method_setter': any(
method['is_check_security_for_frame'] and not method['is_read_only']
for method in methods),
- 'has_method_configuration': any(method['do_generate_method_configuration'] for method in methods),
- 'has_per_context_enabled_methods': any(method['per_context_enabled_function'] for method in methods),
+ 'method_configuration_methods': method_configuration_methods,
+ 'per_context_enabled_methods': per_context_enabled_methods,
'methods': methods,
})
@@ -383,6 +406,16 @@ def generate_overloads(overloads):
not common_value(overloads, 'runtime_enabled_function')):
raise ValueError('Function.length of %s depends on runtime enabled features' % overloads[0]['name'])
+ # Check and fail if overloads disagree on any of the extended attributes
+ # that affect how the method should be registered.
+ # Skip the check for overloaded constructors, since they don't support any
+ # of the extended attributes in question.
+ if not overloads[0].get('is_constructor'):
Nils Barth (inactive) 2014/06/11 10:10:28 nit: Normally we'd combine these into a single boo
+ if (common_value(overloads, 'is_do_not_check_security') is None or
Nils Barth (inactive) 2014/06/11 10:10:28 This is a bit indirect and hence fragile, going vi
Jens Widell 2014/06/11 10:20:57 Sounds good, except at this point I only have what
+ common_value(overloads, 'is_do_not_check_signature') is None or
+ common_value(overloads, 'property_attributes') is None):
+ raise ValueError('Overloads of %s have conflicting extended attributes' % overloads[0]['name'])
Nils Barth (inactive) 2014/06/11 10:10:28 Could you factor out a helper variable: name = ove
+
return {
'deprecate_all_as': common_value(overloads, 'deprecate_as'), # [DeprecateAs]
'length_tests_methods': length_tests_methods(effective_overloads_by_length),
@@ -391,6 +424,9 @@ def generate_overloads(overloads):
# entries in S.
'maxarg': lengths[-1],
'measure_all_as': common_value(overloads, 'measure_as'), # [MeasureAs]
+ 'has_custom_registration_all': common_value(overloads, 'has_custom_registration'),
+ 'per_context_enabled_function_all': common_value(overloads, 'per_context_enabled_function'), # [PerContextEnabled]
+ 'runtime_enabled_function_all': common_value(overloads, 'runtime_enabled_function'), # [RuntimeEnabled]
'valid_arities': lengths
# Only need to report valid arities if there is a gap in the
# sequence of possible lengths, otherwise invalid length means
« no previous file with comments | « no previous file | Source/bindings/scripts/v8_methods.py » ('j') | Source/bindings/scripts/v8_methods.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698