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

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

Issue 424163002: Enable the WebIDL [Exposed] annotation on an interface's members. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: second iteration Created 6 years, 5 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 | « Source/bindings/scripts/v8_methods.py ('k') | Source/bindings/templates/interface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/v8_utilities.py
diff --git a/Source/bindings/scripts/v8_utilities.py b/Source/bindings/scripts/v8_utilities.py
index 674a1b8d9969b08a53404147c1c7e289db1f73f4..39acb1a0fdc36653ff9907d7c389081d5669212f 100644
--- a/Source/bindings/scripts/v8_utilities.py
+++ b/Source/bindings/scripts/v8_utilities.py
@@ -74,6 +74,15 @@ def has_extended_attribute_value(definition_or_member, name, value):
extended_attribute_value_contains(extended_attributes[name], value))
+def sorted_extended_attribute_set(definition_or_member, name):
+ extended_attributes = definition_or_member.extended_attributes
+ if name not in extended_attributes:
+ return set()
+
+ attribute_values = re.split('[|&]', extended_attributes[name])
+ return set(sorted(attribute_values))
Jens Widell 2014/07/30 15:16:18 This doesn't work. It's the construction of the se
+
+
################################################################################
# String handling
################################################################################
@@ -225,6 +234,48 @@ def deprecate_as(member):
return extended_attributes['DeprecateAs']
+# [Exposed]
+EXPOSED_EXECUTION_CONTEXT_METHOD = {
+ 'DedicatedWorker': 'isDedicatedWorkerGlobalScope',
+ 'ServiceWorker': 'isServiceWorkerGlobalScope',
+ 'SharedWorker': 'isSharedWorkerGlobalScope',
+ 'Window': 'isDocument',
+ 'Worker': 'isWorkerGlobalScope',
+}
+
+def exposed(definition_or_member, interface):
+ extended_attributes = definition_or_member.extended_attributes
+ if 'Exposed' not in extended_attributes:
+ return None
+
+ exposure_set = sorted_extended_attribute_set(definition_or_member, 'Exposed')
+ interface_exposure_set = expanded_exposure_set_for_interface(interface)
+
+ # Methods must not be exposed to a broader scope than their interface.
+ if not exposure_set.issubset(interface_exposure_set):
+ raise Exception('Interface members\' exposure sets must be a subset of the interface\'s.')
+
+ exposure_checks = []
+ for environment in exposure_set:
+ # Methods must be exposed on one of the scopes known to Blink.
+ if environment not in EXPOSED_EXECUTION_CONTEXT_METHOD:
+ raise Exception('Values for the [Exposed] annotation must reflect to a valid exposure scope.')
+
+ exposure_checks.append('context->%s()' % EXPOSED_EXECUTION_CONTEXT_METHOD[environment])
+
+ return ' || '.join(exposure_checks)
+
+
+def expanded_exposure_set_for_interface(interface):
+ exposure_set = sorted_extended_attribute_set(interface, 'Exposed')
+
+ # "Worker" is an aggregation for the different kinds of workers.
+ if 'Worker' in exposure_set:
+ exposure_set.update(('DedicatedWorker', 'SharedWorker', 'ServiceWorker'))
+
+ return set(sorted(exposure_set))
+
+
# [GarbageCollected], [WillBeGarbageCollected]
def gc_type(definition):
extended_attributes = definition.extended_attributes
« no previous file with comments | « Source/bindings/scripts/v8_methods.py ('k') | Source/bindings/templates/interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698