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

Side by Side Diff: Source/bindings/scripts/unstable/v8_interface.py

Issue 114813006: IDL compiler: [SetReference] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 if parent_interface: 67 if parent_interface:
68 header_includes.update(v8_types.includes_for_type(parent_interface)) 68 header_includes.update(v8_types.includes_for_type(parent_interface))
69 extended_attributes = interface.extended_attributes 69 extended_attributes = interface.extended_attributes
70 70
71 # [CheckSecurity] 71 # [CheckSecurity]
72 is_check_security = 'CheckSecurity' in extended_attributes 72 is_check_security = 'CheckSecurity' in extended_attributes
73 if is_check_security: 73 if is_check_security:
74 includes.add('bindings/v8/BindingSecurity.h') 74 includes.add('bindings/v8/BindingSecurity.h')
75 75
76 # [GenerateVisitDOMWrapper] 76 # [GenerateVisitDOMWrapper]
77 generate_visit_dom_wrapper_function = extended_attributes.get('GenerateVisit DOMWrapper') 77 check_reachable_method = extended_attributes.get('GenerateVisitDOMWrapper')
78 if generate_visit_dom_wrapper_function: 78 if check_reachable_method:
79 includes.update(['bindings/v8/V8GCController.h', 79 includes.update(['bindings/v8/V8GCController.h',
80 'core/dom/Element.h']) 80 'core/dom/Element.h'])
81 81
82 # [MeasureAs] 82 # [MeasureAs]
83 is_measure_as = 'MeasureAs' in extended_attributes 83 is_measure_as = 'MeasureAs' in extended_attributes
84 if is_measure_as: 84 if is_measure_as:
85 includes.add('core/frame/UseCounter.h') 85 includes.add('core/frame/UseCounter.h')
86 86
87 # [SetReference]
88 set_reference_list = [{
89 'name': argument.name,
90 'idl_type': argument.idl_type,
91 'v8_type': v8_types.v8_type(argument.idl_type),
92 } for argument in extended_attributes.get('SetReference', [])]
93 for set_reference in set_reference_list:
94 v8_types.add_includes_for_type(set_reference['idl_type'])
95
87 # [SpecialWrapFor] 96 # [SpecialWrapFor]
88 if 'SpecialWrapFor' in extended_attributes: 97 if 'SpecialWrapFor' in extended_attributes:
89 special_wrap_for = extended_attributes['SpecialWrapFor'].split('|') 98 special_wrap_for = extended_attributes['SpecialWrapFor'].split('|')
90 else: 99 else:
91 special_wrap_for = [] 100 special_wrap_for = []
92 for special_wrap_interface in special_wrap_for: 101 for special_wrap_interface in special_wrap_for:
93 v8_types.add_includes_for_type(special_wrap_interface) 102 v8_types.add_includes_for_type(special_wrap_interface)
94 103
95 # Constructors 104 # Constructors
96 constructors = [generate_constructor(interface, constructor) 105 constructors = [generate_constructor(interface, constructor)
(...skipping 28 matching lines...) Expand all
125 named_constructor = {'name': extended_attributes['NamedConstructor']} 134 named_constructor = {'name': extended_attributes['NamedConstructor']}
126 else: 135 else:
127 named_constructor = None 136 named_constructor = None
128 137
129 if (constructors or custom_constructors or has_event_constructor or 138 if (constructors or custom_constructors or has_event_constructor or
130 named_constructor): 139 named_constructor):
131 includes.add('bindings/v8/V8ObjectConstructor.h') 140 includes.add('bindings/v8/V8ObjectConstructor.h')
132 141
133 template_contents = { 142 template_contents = {
134 'any_type_attributes': any_type_attributes, 143 'any_type_attributes': any_type_attributes,
144 'check_reachable_method': check_reachable_method,
135 'conditional_string': conditional_string(interface), # [Conditional] 145 'conditional_string': conditional_string(interface), # [Conditional]
136 'constructors': constructors, 146 'constructors': constructors,
137 'cpp_class': cpp_name(interface), 147 'cpp_class': cpp_name(interface),
138 'generate_visit_dom_wrapper_function': generate_visit_dom_wrapper_functi on,
139 'has_custom_constructor': bool(custom_constructors), 148 'has_custom_constructor': bool(custom_constructors),
140 'has_custom_legacy_call_as_function': has_extended_attribute_value(inter face, 'Custom', 'LegacyCallAsFunction'), # [Custom=LegacyCallAsFunction] 149 'has_custom_legacy_call_as_function': has_extended_attribute_value(inter face, 'Custom', 'LegacyCallAsFunction'), # [Custom=LegacyCallAsFunction]
141 'has_custom_to_v8': has_extended_attribute_value(interface, 'Custom', 'T oV8'), # [Custom=ToV8] 150 'has_custom_to_v8': has_extended_attribute_value(interface, 'Custom', 'T oV8'), # [Custom=ToV8]
142 'has_custom_wrap': has_extended_attribute_value(interface, 'Custom', 'Wr ap'), # [Custom=Wrap] 151 'has_custom_wrap': has_extended_attribute_value(interface, 'Custom', 'Wr ap'), # [Custom=Wrap]
143 'has_event_constructor': has_event_constructor, 152 'has_event_constructor': has_event_constructor,
144 'has_visit_dom_wrapper': ( 153 'has_visit_dom_wrapper': (
145 # [Custom=Wrap], [GenerateVisitDOMWrapper] 154 # [Custom=Wrap], [GenerateVisitDOMWrapper]
146 has_extended_attribute_value(interface, 'Custom', 'VisitDOMWrapper') or 155 has_extended_attribute_value(interface, 'Custom', 'VisitDOMWrapper') or
147 'GenerateVisitDOMWrapper' in extended_attributes), 156 check_reachable_method or set_reference_list),
148 'header_includes': header_includes, 157 'header_includes': header_includes,
149 'interface_length': 158 'interface_length':
150 interface_length(interface, constructors + custom_constructors), 159 interface_length(interface, constructors + custom_constructors),
151 'interface_name': interface.name, 160 'interface_name': interface.name,
152 'is_active_dom_object': 'ActiveDOMObject' in extended_attributes, # [Ac tiveDOMObject] 161 'is_active_dom_object': 'ActiveDOMObject' in extended_attributes, # [Ac tiveDOMObject]
153 'is_check_security': is_check_security, 162 'is_check_security': is_check_security,
154 'is_constructor_call_with_document': has_extended_attribute_value( 163 'is_constructor_call_with_document': has_extended_attribute_value(
155 interface, 'ConstructorCallWith', 'Document'), # [ConstructorCallWi th=Document] 164 interface, 'ConstructorCallWith', 'Document'), # [ConstructorCallWi th=Document]
156 'is_constructor_call_with_execution_context': has_extended_attribute_val ue( 165 'is_constructor_call_with_execution_context': has_extended_attribute_val ue(
157 interface, 'ConstructorCallWith', 'ExecutionContext'), # [Construct orCallWith=ExeuctionContext] 166 interface, 'ConstructorCallWith', 'ExecutionContext'), # [Construct orCallWith=ExeuctionContext]
158 'is_constructor_raises_exception': extended_attributes.get('RaisesExcept ion') == 'Constructor', # [RaisesException=Constructor] 167 'is_constructor_raises_exception': extended_attributes.get('RaisesExcept ion') == 'Constructor', # [RaisesException=Constructor]
159 'is_dependent_lifetime': 'DependentLifetime' in extended_attributes, # [DependentLifetime] 168 'is_dependent_lifetime': 'DependentLifetime' in extended_attributes, # [DependentLifetime]
160 'is_event_target': inherits_interface(interface, 'EventTarget'), 169 'is_event_target': inherits_interface(interface, 'EventTarget'),
161 'is_node': inherits_interface(interface, 'Node'), 170 'is_node': inherits_interface(interface, 'Node'),
162 'measure_as': v8_utilities.measure_as(interface), # [MeasureAs] 171 'measure_as': v8_utilities.measure_as(interface), # [MeasureAs]
163 'named_constructor': named_constructor, 172 'named_constructor': named_constructor,
164 'parent_interface': parent_interface, 173 'parent_interface': parent_interface,
165 'runtime_enabled_function': runtime_enabled_function_name(interface), # [RuntimeEnabled] 174 'runtime_enabled_function': runtime_enabled_function_name(interface), # [RuntimeEnabled]
175 'set_reference_list': set_reference_list,
166 'special_wrap_for': special_wrap_for, 176 'special_wrap_for': special_wrap_for,
167 'v8_class': v8_utilities.v8_class_name(interface), 177 'v8_class': v8_utilities.v8_class_name(interface),
168 } 178 }
169 179
170 template_contents.update({ 180 template_contents.update({
171 'constants': [generate_constant(constant) for constant in interface.cons tants], 181 'constants': [generate_constant(constant) for constant in interface.cons tants],
172 'do_not_check_constants': 'DoNotCheckConstants' in extended_attributes, 182 'do_not_check_constants': 'DoNotCheckConstants' in extended_attributes,
173 }) 183 })
174 184
175 attributes = [v8_attributes.generate_attribute(interface, attribute) 185 attributes = [v8_attributes.generate_attribute(interface, attribute)
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 return min(constructor['number_of_required_arguments'] 412 return min(constructor['number_of_required_arguments']
403 for constructor in constructors) 413 for constructor in constructors)
404 414
405 415
406 # Interface dependencies 416 # Interface dependencies
407 417
408 def inherits_interface(interface, ancestor): 418 def inherits_interface(interface, ancestor):
409 # FIXME: support distant ancestors (but don't parse all ancestors!) 419 # FIXME: support distant ancestors (but don't parse all ancestors!)
410 # Do by computing ancestor chain in compute_dependencies.py 420 # Do by computing ancestor chain in compute_dependencies.py
411 return ancestor in [interface.name, interface.parent] 421 return ancestor in [interface.name, interface.parent]
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698