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

Side by Side Diff: third_party/WebKit/Source/bindings/scripts/v8_attributes.py

Issue 2376913002: [Bindings] Drop a global variable 'interfaces' in v8_globals (Closed)
Patch Set: Update documents Created 4 years, 2 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
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
11 # in the documentation and/or other materials provided with the 11 # in the documentation and/or other materials provided with the
12 # distribution. 12 # distribution.
13 # * Neither the name of Google Inc. nor the names of its 13 # * Neither the name of Google Inc. nor the names of its
14 # contributors may be used to endorse or promote products derived from 14 # contributors may be used to endorse or promote products derived from
15 # this software without specific prior written permission. 15 # this software without specific prior written permission.
16 # 16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 28
29 # pylint: disable=relative-import
30
29 """Generate template values for attributes. 31 """Generate template values for attributes.
30 32
31 Extends IdlType with property |constructor_type_name|. 33 Extends IdlType with property |constructor_type_name|.
32 34
33 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler 35 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler
34 """ 36 """
35 37
36 import idl_types 38 import idl_types
37 from idl_types import inherits_interface 39 from idl_types import inherits_interface
38 from v8_globals import includes, interfaces 40 from v8_globals import includes
39 import v8_types 41 import v8_types
40 import v8_utilities 42 import v8_utilities
41 from v8_utilities import (cpp_name_or_partial, capitalize, cpp_name, has_extende d_attribute, 43 from v8_utilities import (cpp_name_or_partial, capitalize, cpp_name, has_extende d_attribute,
42 has_extended_attribute_value, scoped_name, strip_suffi x, 44 has_extended_attribute_value, scoped_name, strip_suffi x,
43 uncapitalize, extended_attribute_value_as_list, is_unf orgeable, 45 uncapitalize, extended_attribute_value_as_list, is_unf orgeable,
44 is_legacy_interface_type_checking) 46 is_legacy_interface_type_checking)
45 47
46 48
47 def attribute_context(interface, attribute): 49 def attribute_context(interface, attribute, interfaces):
50 """Creates a Jinja template context for an attribute of an interface.
51
52 Args:
53 interface: An interface which |attribute| belongs to
54 attribute: An attribute to create the context for
55 interfaces: A dict which maps an interface name to the definition
56 which can be referred if needed
57
58 Returns:
59 A Jinja template context for |attribute|
60 """
61
48 idl_type = attribute.idl_type 62 idl_type = attribute.idl_type
49 base_idl_type = idl_type.base_type 63 base_idl_type = idl_type.base_type
50 extended_attributes = attribute.extended_attributes 64 extended_attributes = attribute.extended_attributes
51 65
52 idl_type.add_includes_for_type(extended_attributes) 66 idl_type.add_includes_for_type(extended_attributes)
53 if idl_type.enum_values: 67 if idl_type.enum_values:
54 includes.add('core/inspector/ConsoleMessage.h') 68 includes.add('core/inspector/ConsoleMessage.h')
55 69
56 # [CheckSecurity] 70 # [CheckSecurity]
57 is_do_not_check_security = 'DoNotCheckSecurity' in extended_attributes 71 is_do_not_check_security = 'DoNotCheckSecurity' in extended_attributes
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 ['', 'ForMainWorld'] 188 ['', 'ForMainWorld']
175 if 'PerWorldBindings' in extended_attributes 189 if 'PerWorldBindings' in extended_attributes
176 else ['']), # [PerWorldBindings] 190 else ['']), # [PerWorldBindings]
177 } 191 }
178 192
179 if is_constructor_attribute(attribute): 193 if is_constructor_attribute(attribute):
180 update_constructor_attribute_context(interface, attribute, context) 194 update_constructor_attribute_context(interface, attribute, context)
181 if not has_custom_getter(attribute): 195 if not has_custom_getter(attribute):
182 getter_context(interface, attribute, context) 196 getter_context(interface, attribute, context)
183 if not has_custom_setter(attribute) and has_setter(interface, attribute): 197 if not has_custom_setter(attribute) and has_setter(interface, attribute):
184 setter_context(interface, attribute, context) 198 setter_context(interface, attribute, interfaces, context)
185 199
186 return context 200 return context
187 201
188 202
189 def filter_has_accessor_configuration(attributes): 203 def filter_has_accessor_configuration(attributes):
190 return [attribute for attribute in attributes if 204 return [attribute for attribute in attributes if
191 not (attribute['exposed_test'] or 205 not (attribute['exposed_test'] or
192 attribute['secure_context_test'] or 206 attribute['secure_context_test'] or
193 attribute['origin_trial_enabled_function'] or 207 attribute['origin_trial_enabled_function'] or
194 attribute['runtime_enabled_function']) and 208 attribute['runtime_enabled_function']) and
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 attribute.name == 'self' or 372 attribute.name == 'self' or
359 # FIXME: Remove these hard-coded hacks. 373 # FIXME: Remove these hard-coded hacks.
360 base_idl_type in ['EventTarget', 'Window'] or 374 base_idl_type in ['EventTarget', 'Window'] or
361 base_idl_type.startswith(('HTML', 'SVG'))))) 375 base_idl_type.startswith(('HTML', 'SVG')))))
362 376
363 377
364 ################################################################################ 378 ################################################################################
365 # Setter 379 # Setter
366 ################################################################################ 380 ################################################################################
367 381
368 def setter_context(interface, attribute, context): 382 def setter_context(interface, attribute, interfaces, context):
369 if 'PutForwards' in attribute.extended_attributes: 383 if 'PutForwards' in attribute.extended_attributes:
370 # Use target interface and attribute in place of original interface and 384 # Use target interface and attribute in place of original interface and
371 # attribute from this point onwards. 385 # attribute from this point onwards.
372 target_interface_name = attribute.idl_type.base_type 386 target_interface_name = attribute.idl_type.base_type
373 target_attribute_name = attribute.extended_attributes['PutForwards'] 387 target_attribute_name = attribute.extended_attributes['PutForwards']
374 interface = interfaces[target_interface_name] 388 interface = interfaces[target_interface_name]
375 try: 389 try:
376 attribute = next(candidate 390 attribute = next(candidate
377 for candidate in interface.attributes 391 for candidate in interface.attributes
378 if candidate.name == target_attribute_name) 392 if candidate.name == target_attribute_name)
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 lambda self: strip_suffix(self.base_type, 'Constructor')) 582 lambda self: strip_suffix(self.base_type, 'Constructor'))
569 583
570 584
571 def is_constructor_attribute(attribute): 585 def is_constructor_attribute(attribute):
572 # FIXME: replace this with [ConstructorAttribute] extended attribute 586 # FIXME: replace this with [ConstructorAttribute] extended attribute
573 return attribute.idl_type.name.endswith('Constructor') 587 return attribute.idl_type.name.endswith('Constructor')
574 588
575 589
576 def update_constructor_attribute_context(interface, attribute, context): 590 def update_constructor_attribute_context(interface, attribute, context):
577 context['needs_constructor_getter_callback'] = context['measure_as'] or cont ext['deprecate_as'] 591 context['needs_constructor_getter_callback'] = context['measure_as'] or cont ext['deprecate_as']
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698