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

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

Issue 789473002: Introduce [Exposed(Arguments)] in IDL code generator. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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/idl_definitions.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/generate_global_constructors.py
diff --git a/Source/bindings/scripts/generate_global_constructors.py b/Source/bindings/scripts/generate_global_constructors.py
index 1be2ac3327c730f529759f552f658bfeff42f7c5..9f01d6777cd6ea50ffa64fae27622649c9af2aa9 100755
--- a/Source/bindings/scripts/generate_global_constructors.py
+++ b/Source/bindings/scripts/generate_global_constructors.py
@@ -25,7 +25,7 @@ import re
import sys
from collections import defaultdict
-from utilities import get_file_contents, idl_filename_to_interface_name, read_file_to_list, write_file, get_interface_extended_attributes_from_idl, is_callback_interface_from_idl
+from utilities import get_file_contents, idl_filename_to_interface_name, read_file_to_list, write_file, get_interface_extended_attributes_from_idl, get_interface_exposed_arguments, is_callback_interface_from_idl
interface_name_to_global_names = {}
global_name_to_constructors = defaultdict(list)
@@ -81,15 +81,22 @@ def record_global_constructors(idl_filename):
'NoInterfaceObject' in extended_attributes):
return
- # The [Exposed] extended attribute MUST take an identifier list. Each
- # identifier in the list MUST be a global name. An interface or interface
- # member the extended attribute applies to will be exposed only on objects
- # associated with ECMAScript global environments whose global object
- # implements an interface that has a matching global name.
- exposed_global_names = extended_attributes.get('Exposed', 'Window').strip('()').split(',')
- new_constructors_list = generate_global_constructors_list(interface_name, extended_attributes)
- for exposed_global_name in exposed_global_names:
- global_name_to_constructors[exposed_global_name].extend(new_constructors_list)
+ exposed_arguments = get_interface_exposed_arguments(idl_file_contents)
+ if exposed_arguments:
+ # Exposed(Arguments) case
+ for argument in exposed_arguments:
+ if 'RuntimeEnabled' in extended_attributes:
+ raise ValueError('RuntimeEnabled should not be used with Exposed(Arguments)')
+ attributes = extended_attributes.copy()
+ attributes['RuntimeEnabled'] = argument['runtime_enabled']
+ new_constructors_list = generate_global_constructors_list(interface_name, attributes)
+ global_name_to_constructors[argument['exposed']].extend(new_constructors_list)
+ else:
+ # Exposed=env or Exposed=(env1,...) case
+ exposed_global_names = extended_attributes.get('Exposed', 'Window').strip('()').split(',')
+ new_constructors_list = generate_global_constructors_list(interface_name, extended_attributes)
+ for name in exposed_global_names:
+ global_name_to_constructors[name].extend(new_constructors_list)
def generate_global_constructors_list(interface_name, extended_attributes):
« no previous file with comments | « no previous file | Source/bindings/scripts/idl_definitions.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698