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

Unified Diff: Source/bindings/scripts/idl_definitions.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 | « Source/bindings/scripts/generate_global_constructors.py ('k') | Source/bindings/scripts/utilities.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/idl_definitions.py
diff --git a/Source/bindings/scripts/idl_definitions.py b/Source/bindings/scripts/idl_definitions.py
index 179f587f6a6c17a3f059ed99b21c624737426509..ce978647117f4457440bf6c865c52a0f66d8a8de 100644
--- a/Source/bindings/scripts/idl_definitions.py
+++ b/Source/bindings/scripts/idl_definitions.py
@@ -650,6 +650,17 @@ class IdlImplement(object):
# Extended attributes
################################################################################
+class Exposure:
+ """An Exposure holds one Exposed or RuntimeEnabled condition.
+ Each exposure has two properties: exposed and runtime_enabled.
+ Exposure(e, r) corresponds to [Exposed(e r)]. Exposure(e) corresponds to
+ [Exposed=e].
+ """
+ def __init__(self, exposed, runtime_enabled=None):
+ self.exposed = exposed
+ self.runtime_enabled = runtime_enabled
+
+
def ext_attributes_node_to_extended_attributes(idl_name, node):
"""
Returns:
@@ -706,6 +717,21 @@ def ext_attributes_node_to_extended_attributes(idl_name, node):
if child_class != 'Arguments':
raise ValueError('[SetWrapperReferenceTo] only supports Arguments as child, but has child of class: %s' % child_class)
extended_attributes[name] = arguments_node_to_arguments(idl_name, child)
+ elif name == 'Exposed':
+ if child_class and child_class != 'Arguments':
+ raise ValueError('[Exposed] only supports Arguments as child, but has child of class: %s' % child_class)
+ exposures = []
+ if child_class == 'Arguments':
+ exposures = [Exposure(exposed=str(arg.idl_type),
+ runtime_enabled=arg.name)
+ for arg in arguments_node_to_arguments('*', child)]
+ else:
+ value = extended_attribute_node.GetProperty('VALUE')
+ if type(value) is str:
+ exposures = [Exposure(exposed=value)]
+ else:
+ exposures = [Exposure(exposed=v) for v in value]
+ extended_attributes[name] = exposures
elif child:
raise ValueError('ExtAttributes node with unexpected children: %s' % name)
else:
« no previous file with comments | « Source/bindings/scripts/generate_global_constructors.py ('k') | Source/bindings/scripts/utilities.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698