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

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
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..28a2a190b18e93a6366d7ccaf5ab4cbc5104ac58 100644
--- a/Source/bindings/scripts/idl_definitions.py
+++ b/Source/bindings/scripts/idl_definitions.py
@@ -650,6 +650,16 @@ class IdlImplement(object):
# Extended attributes
################################################################################
+class Exposure:
+ """An Exposure holds one Exposed or RuntimeEnabled condition.
+ Each exposure has two property: exposed and runtime_enabled. Exposure(e, r)
haraken 2014/12/09 16:07:55 property => properties
yhirano 2014/12/11 01:38:25 Done.
+ corresponds to [Exposed(e r)]. Exposure(e) corresponds to [Exposed=e].
haraken 2014/12/09 16:07:56 [Exposed(e r)] => [Exposed(e, r)] ?
Jens Widell 2014/12/09 16:19:23 The extended attribute syntax is [Exposed(e r)], o
yhirano 2014/12/11 01:38:25 It's like Exposed(Window GlobalFetch, ServiceWorke
+ """
+ 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 +716,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:

Powered by Google App Engine
This is Rietveld 408576698