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

Unified Diff: third_party/WebKit/Source/bindings/scripts/v8_interface.py

Issue 2813023002: [Bindings] Make maplike<> and setlike<> imply a readonly size attribute. (Closed)
Patch Set: merge with 23752147e6f5f7dcaf4bad1bb1c306fb91e1ec5b Created 3 years, 8 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
Index: third_party/WebKit/Source/bindings/scripts/v8_interface.py
diff --git a/third_party/WebKit/Source/bindings/scripts/v8_interface.py b/third_party/WebKit/Source/bindings/scripts/v8_interface.py
index bc379f6a78a5d272f4e15535dbfa12e32cea6852..ec4499fcb5d061724ebaed6b60d868bca02d26c2 100644
--- a/third_party/WebKit/Source/bindings/scripts/v8_interface.py
+++ b/third_party/WebKit/Source/bindings/scripts/v8_interface.py
@@ -35,7 +35,7 @@ Design doc: http://www.chromium.org/developers/design-documents/idl-compiler
"""
from operator import or_
-from idl_definitions import IdlOperation, IdlArgument
+from idl_definitions import IdlAttribute, IdlOperation, IdlArgument
from idl_types import IdlType, inherits_interface
from overload_set_algorithm import effective_overload_set_by_length
from overload_set_algorithm import method_overloads_by_name
@@ -350,13 +350,7 @@ def interface_context(interface, interfaces):
})
# Attributes
- attributes = [v8_attributes.attribute_context(interface, attribute, interfaces)
- for attribute in interface.attributes]
-
- has_conditional_attributes = any(attribute['exposed_test'] for attribute in attributes)
- if has_conditional_attributes and interface.is_partial:
- raise Exception('Conditional attributes between partial interfaces in modules and the original interfaces(%s) in core are not allowed.' % interface.name)
-
+ attributes = attributes_context(interface, interfaces)
context.update({
'attributes': attributes,
# Elements in attributes are broken in following members.
@@ -462,6 +456,45 @@ def interface_context(interface, interfaces):
return context
+def attributes_context(interface, interfaces):
+ """Creates a list of Jinja template contexts for attributes of an interface.
+
+ Args:
+ interface: An interface to create contexts for
+ interfaces: A dict which maps an interface name to the definition
+ which can be referred if needed
+
+ Returns:
+ A list of attribute contexts
+ """
+
+ attributes = [v8_attributes.attribute_context(interface, attribute, interfaces)
+ for attribute in interface.attributes]
+
+ has_conditional_attributes = any(attribute['exposed_test'] for attribute in attributes)
+ if has_conditional_attributes and interface.is_partial:
+ raise Exception(
+ 'Conditional attributes between partial interfaces in modules '
+ 'and the original interfaces(%s) in core are not allowed.'
+ % interface.name)
+
+ # See also comment in methods_context.
+ if not interface.is_partial and (interface.maplike or interface.setlike):
+ if any(attribute['name'] == 'size' for attribute in attributes):
+ raise ValueError(
+ 'An interface cannot define an attribute called "size"; it is '
+ 'implied by maplike/setlike in the IDL.')
+ size_attribute = IdlAttribute()
+ size_attribute.name = 'size'
+ size_attribute.idl_type = IdlType('unsigned long')
+ size_attribute.is_read_only = True
+ size_attribute.extended_attributes['NotEnumerable'] = None
+ attributes.append(v8_attributes.attribute_context(
+ interface, size_attribute, interfaces))
+
+ return attributes
+
+
def methods_context(interface):
"""Creates a list of Jinja template contexts for methods of an interface.

Powered by Google App Engine
This is Rietveld 408576698