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

Side by Side 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: Rebased 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (C) 2013 Google Inc. All rights reserved. 1 # Copyright (C) 2013 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 template_contents.update({ 200 template_contents.update({
201 'attributes': attributes, 201 'attributes': attributes,
202 'has_accessors': any(attribute['is_expose_js_accessors'] for attribute i n attributes), 202 'has_accessors': any(attribute['is_expose_js_accessors'] for attribute i n attributes),
203 'has_constructor_attributes': any(attribute['constructor_type'] for attr ibute in attributes), 203 'has_constructor_attributes': any(attribute['constructor_type'] for attr ibute in attributes),
204 'has_per_context_enabled_attributes': any(attribute['per_context_enabled _function'] for attribute in attributes), 204 'has_per_context_enabled_attributes': any(attribute['per_context_enabled _function'] for attribute in attributes),
205 'has_replaceable_attributes': any(attribute['is_replaceable'] for attrib ute in attributes), 205 'has_replaceable_attributes': any(attribute['is_replaceable'] for attrib ute in attributes),
206 }) 206 })
207 207
208 # Methods 208 # Methods
209 methods = [v8_methods.generate_method(interface, method) 209 methods = [v8_methods.generate_method(interface, method)
210 for method in interface.operations] 210 for method in interface.operations
211 if method.name] # Skip anonymous special operations (methods)
211 generate_overloads(methods) 212 generate_overloads(methods)
212 for method in methods: 213 for method in methods:
213 method['do_generate_method_configuration'] = ( 214 method['do_generate_method_configuration'] = (
214 method['do_not_check_signature'] and 215 method['do_not_check_signature'] and
215 not method['per_context_enabled_function'] and 216 not method['per_context_enabled_function'] and
216 # For overloaded methods, only generate one accessor 217 # For overloaded methods, only generate one accessor
217 ('overload_index' not in method or method['overload_index'] == 1)) 218 ('overload_index' not in method or method['overload_index'] == 1))
218 219
219 template_contents.update({ 220 template_contents.update({
220 'has_origin_safe_method_setter': any( 221 'has_origin_safe_method_setter': any(
221 method['is_check_security_for_frame'] and not method['is_read_only'] 222 method['is_check_security_for_frame'] and not method['is_read_only']
222 for method in methods), 223 for method in methods),
223 'has_method_configuration': any(method['do_generate_method_configuration '] for method in methods), 224 'has_method_configuration': any(method['do_generate_method_configuration '] for method in methods),
224 'has_per_context_enabled_methods': any(method['per_context_enabled_funct ion'] for method in methods), 225 'has_per_context_enabled_methods': any(method['per_context_enabled_funct ion'] for method in methods),
225 'methods': methods, 226 'methods': methods,
226 }) 227 })
227 228
229 template_contents.update({
230 'anonymous_indexed_property_getter': anonymous_indexed_property_getter(i nterface),
231 })
232
228 return template_contents 233 return template_contents
229 234
230 235
231 # [DeprecateAs], [Reflect], [RuntimeEnabled] 236 # [DeprecateAs], [Reflect], [RuntimeEnabled]
232 def generate_constant(constant): 237 def generate_constant(constant):
233 # (Blink-only) string literals are unquoted in tokenizer, must be re-quoted 238 # (Blink-only) string literals are unquoted in tokenizer, must be re-quoted
234 # in C++. 239 # in C++.
235 if constant.idl_type == 'DOMString': 240 if constant.idl_type == 'DOMString':
236 value = '"%s"' % constant.value 241 value = '"%s"' % constant.value
237 else: 242 else:
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 467
463 468
464 def interface_length(interface, constructors): 469 def interface_length(interface, constructors):
465 # Docs: http://heycam.github.io/webidl/#es-interface-call 470 # Docs: http://heycam.github.io/webidl/#es-interface-call
466 if 'EventConstructor' in interface.extended_attributes: 471 if 'EventConstructor' in interface.extended_attributes:
467 return 1 472 return 1
468 if not constructors: 473 if not constructors:
469 return 0 474 return 0
470 return min(constructor['number_of_required_arguments'] 475 return min(constructor['number_of_required_arguments']
471 for constructor in constructors) 476 for constructor in constructors)
477
478
479 ################################################################################
480 # Special operations (methods)
481 # http://heycam.github.io/webidl/#idl-special-operations
482 ################################################################################
483
484 def anonymous_indexed_property_getter(interface):
485 try:
486 getter = next(
487 method
488 for method in interface.operations
489 if ('getter' in method.specials and
490 len(method.arguments) == 1 and
491 method.arguments[0].idl_type == 'unsigned long' and
492 not method.name))
493 except StopIteration:
494 return None
495
496 idl_type = getter.idl_type
497 extended_attributes = getter.extended_attributes
498 return {
499 'cpp_type': v8_types.cpp_type(idl_type),
500 'is_null_expression': getter_is_null_expression(idl_type),
501 'name': extended_attributes['ImplementedAs'],
502 'v8_set_return_value': v8_types.v8_set_return_value(idl_type, 'element', extended_attributes=extended_attributes, script_wrappable='collection'),
503 }
504
505
506 def getter_is_null_expression(idl_type):
507 if idl_type == 'DOMString':
508 return 'element.isNull()'
509 return None
OLDNEW
« no previous file with comments | « Source/bindings/scripts/code_generator_v8.pm ('k') | Source/bindings/scripts/unstable/v8_methods.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698