Chromium Code Reviews| 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..4c2dbbb32652f574ef04ab49c065e124f59494a5 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_list(definition_or_member, name): |
| + extended_attributes = definition_or_member.extended_attributes |
| + if name not in extended_attributes: |
| + return [] |
| + |
| + attribute_values = re.split('[|&]', extended_attributes[name]) |
| + return sorted(attribute_values) |
| + |
| + |
| ################################################################################ |
| # 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 |
|
Jens Widell
2014/07/30 16:48:45
This local is only used once, on the line below, a
Peter Beverloo
2014/07/31 19:02:21
Done.
|
| + if 'Exposed' not in extended_attributes: |
| + return None |
| + |
| + exposure_list = sorted_extended_attribute_list(definition_or_member, 'Exposed') |
|
Jens Widell
2014/07/30 16:48:45
I think you could have stuck with 'exposure_set' h
Peter Beverloo
2014/07/31 19:02:21
I'm in dubio. It would indeed describe the content
|
| + interface_exposure_list = expanded_exposure_list_for_interface(interface) |
| + |
| + # Methods must not be exposed to a broader scope than their interface. |
| + if not set(exposure_list).issubset(interface_exposure_list): |
| + raise Exception('Interface members\' exposure sets must be a subset of the interface\'s.') |
|
haraken
2014/07/30 16:32:03
Nit: We normally use ValueError instead of Excepti
Peter Beverloo
2014/07/31 19:02:22
Done.
|
| + |
| + exposure_checks = [] |
| + for environment in exposure_list: |
| + # 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.') |
|
haraken
2014/07/30 16:32:03
Ditto.
Peter Beverloo
2014/07/31 19:02:22
Done.
|
| + |
| + exposure_checks.append('context->%s()' % EXPOSED_EXECUTION_CONTEXT_METHOD[environment]) |
| + |
| + return ' || '.join(exposure_checks) |
| + |
| + |
| +def expanded_exposure_list_for_interface(interface): |
| + exposure_list = sorted_extended_attribute_list(interface, 'Exposed') |
| + |
| + # "Worker" is an aggregation for the different kinds of workers. |
| + if 'Worker' in exposure_list: |
| + exposure_list.extend(('DedicatedWorker', 'SharedWorker', 'ServiceWorker')) |
| + |
| + return sorted(set(exposure_list)) |
| + |
| + |
| # [GarbageCollected], [WillBeGarbageCollected] |
| def gc_type(definition): |
| extended_attributes = definition.extended_attributes |