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

Unified Diff: bindings/scripts/v8_utilities.py

Issue 581453002: Dartium Roll 38 roll (Closed) Base URL: https://dart.googlecode.com/svn/third_party/WebCore
Patch Set: Sync'd w/ r 182210 Created 6 years, 3 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 | « bindings/scripts/v8_types.py ('k') | bindings/tests/idls/TestDictionary.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bindings/scripts/v8_utilities.py
diff --git a/bindings/scripts/v8_utilities.py b/bindings/scripts/v8_utilities.py
index 80675951b52752a864be669d06c4a22e96f97df1..4a2b46a5d9587cd743faf5a0bca009a477833c60 100644
--- a/bindings/scripts/v8_utilities.py
+++ b/bindings/scripts/v8_utilities.py
@@ -28,14 +28,14 @@
"""Functions shared by various parts of the code generator.
-Extends IdlType and IdlUnion type with |enum_validation_expression| property.
+Extends IdlTypeBase type with |enum_validation_expression| property.
Design doc: http://www.chromium.org/developers/design-documents/idl-compiler
"""
import re
-from idl_types import IdlType, IdlUnionType
+from idl_types import IdlTypeBase
import idl_types
from v8_globals import includes
import v8_types
@@ -60,7 +60,7 @@ ACRONYMS = [
def extended_attribute_value_contains(extended_attribute_value, value):
return (extended_attribute_value and
- value in re.split('[|&]', extended_attribute_value))
+ value in re.split('[|,]', extended_attribute_value))
def has_extended_attribute(definition_or_member, extended_attribute_list):
@@ -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 []
+
+ attribute_values = re.split('[|,]', extended_attributes[name])
+ return sorted(attribute_values)
+
+
################################################################################
# String handling
################################################################################
@@ -113,10 +122,12 @@ def enum_validation_expression(idl_type):
return None
return ' || '.join(['string == "%s"' % enum_value
for enum_value in idl_type.enum_values])
-IdlType.enum_validation_expression = property(enum_validation_expression)
+IdlTypeBase.enum_validation_expression = property(enum_validation_expression)
def scoped_name(interface, definition, base_name):
+ if 'ImplementedInPrivateScript' in definition.extended_attributes:
+ return '%s::PrivateScript::%s' % (v8_class_name(interface), base_name)
# partial interfaces are implemented as separate classes, with their members
# implemented as static member functions
partial_interface_implemented_as = definition.extended_attributes.get('PartialInterfaceImplementedAs')
@@ -149,7 +160,7 @@ def activity_logging_world_list(member, access_type=''):
if log_activity and not log_activity.startswith(access_type):
return set()
- includes.add('bindings/v8/V8DOMActivityLogger.h')
+ includes.add('bindings/core/v8/V8DOMActivityLogger.h')
if 'LogAllWorlds' in extended_attributes:
return set(['', 'ForMainWorld'])
return set(['']) # At minimum, include isolated worlds.
@@ -201,15 +212,21 @@ def call_with_arguments(call_with_values):
# [Conditional]
+DELIMITER_TO_OPERATOR = {
+ '|': '||',
+ ',': '&&',
+}
+
+
def conditional_string(definition_or_member):
extended_attributes = definition_or_member.extended_attributes
if 'Conditional' not in extended_attributes:
return None
conditional = extended_attributes['Conditional']
- for operator in '&|':
- if operator in conditional:
- conditions = conditional.split(operator)
- operator_separator = ' %s%s ' % (operator, operator)
+ for delimiter in ',|':
+ if delimiter in conditional:
+ conditions = conditional.split(delimiter)
+ operator_separator = ' %s ' % DELIMITER_TO_OPERATOR[delimiter]
return operator_separator.join('ENABLE(%s)' % expression for expression in sorted(conditions))
return 'ENABLE(%s)' % conditional
@@ -223,6 +240,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):
+ exposure_set = sorted_extended_attribute_set(definition_or_member, 'Exposed')
+ if not exposure_set:
+ return None
+
+ interface_exposure_set = expanded_exposure_set_for_interface(interface)
+
+ # Methods must not be exposed to a broader scope than their interface.
+ if not set(exposure_set).issubset(interface_exposure_set):
+ raise ValueError('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 ValueError('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.extend(('DedicatedWorker', 'SharedWorker', 'ServiceWorker'))
+
+ return sorted(set(exposure_set))
+
+
# [GarbageCollected], [WillBeGarbageCollected]
def gc_type(definition):
extended_attributes = definition.extended_attributes
« no previous file with comments | « bindings/scripts/v8_types.py ('k') | bindings/tests/idls/TestDictionary.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698