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

Unified Diff: Source/bindings/scripts/unstable/v8_interface.py

Issue 148083004: IDL compiler: anonymous indexed property getters (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 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: Source/bindings/scripts/unstable/v8_interface.py
diff --git a/Source/bindings/scripts/unstable/v8_interface.py b/Source/bindings/scripts/unstable/v8_interface.py
index 78b1e7205e831a7ac9021d0fc343cfc62db88ff5..1f97a5cf9612fa74ce5fa13574c7239ecdb50812 100644
--- a/Source/bindings/scripts/unstable/v8_interface.py
+++ b/Source/bindings/scripts/unstable/v8_interface.py
@@ -201,7 +201,8 @@ def generate_interface(interface):
})
methods = [v8_methods.generate_method(interface, method)
- for method in interface.operations]
+ for method in interface.operations
+ if method.name] # Skip anonymous special operations (methods)
generate_overloads(methods)
for method in methods:
method['do_generate_method_configuration'] = (
@@ -219,6 +220,10 @@ def generate_interface(interface):
'methods': methods,
})
+ template_contents.update({
+ 'anonymous_indexed_property_getter': generate_anonymous_indexed_property_getter(interface),
+ })
+
return template_contents
@@ -463,3 +468,36 @@ def interface_length(interface, constructors):
return 0
return min(constructor['number_of_required_arguments']
for constructor in constructors)
+
+
+################################################################################
+# Special operations (methods)
+# http://heycam.github.io/webidl/#idl-special-operations
+################################################################################
+
+def generate_anonymous_indexed_property_getter(interface):
+ try:
+ getter = next(
haraken 2014/01/27 06:35:32 This looks a bit complicated. Can we avoid using P
Nils Barth (inactive) 2014/01/27 06:59:35 Admittedly this looks a bit weird, but this is the
haraken 2014/01/27 07:04:40 Understood, thanks for the clarification.
+ method
+ for method in interface.operations
+ if ('getter' in method.specials and
+ len(method.arguments) == 1 and
+ method.arguments[0].idl_type == 'unsigned long' and
+ not method.name))
+ except StopIteration:
+ return None
+
+ idl_type = getter.idl_type
+ extended_attributes = getter.extended_attributes
+ return {
+ 'cpp_type': v8_types.cpp_type(idl_type),
+ 'is_null_expression': getter_is_null_expression(idl_type),
+ 'name': extended_attributes['ImplementedAs'],
haraken 2014/01/27 06:35:32 Why do we need to support [ImplementedAs] for "ano
Nils Barth (inactive) 2014/01/27 06:59:35 See other comment: anonymous means there's no name
haraken 2014/01/27 07:04:40 Sounds better.
Nils Barth (inactive) 2014/01/27 07:24:37 Ok, I'll do this in a followup, as it touches real
+ 'v8_set_return_value': v8_types.v8_set_return_value(idl_type, 'element', extended_attributes=extended_attributes, script_wrappable='collection'),
+ }
+
+
+def getter_is_null_expression(idl_type):
haraken 2014/01/27 06:35:32 Is this method only for getters?
Nils Barth (inactive) 2014/01/27 06:59:35 Yes; I've thus made it explicit.
+ if idl_type == 'DOMString':
+ return 'element.isNull()'
+ return None
haraken 2014/01/27 06:35:32 How can we judge nullability for non-DOMString val
Nils Barth (inactive) 2014/01/27 06:59:35 See GenerateIsNullExpression https://code.google.c

Powered by Google App Engine
This is Rietveld 408576698