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

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

Issue 116153002: IDL compiler: [NamedConstructor] (basic) (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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 # [SpecialWrapFor] 87 # [SpecialWrapFor]
88 if 'SpecialWrapFor' in extended_attributes: 88 if 'SpecialWrapFor' in extended_attributes:
89 special_wrap_for = extended_attributes['SpecialWrapFor'].split('|') 89 special_wrap_for = extended_attributes['SpecialWrapFor'].split('|')
90 else: 90 else:
91 special_wrap_for = [] 91 special_wrap_for = []
92 for special_wrap_interface in special_wrap_for: 92 for special_wrap_interface in special_wrap_for:
93 v8_types.add_includes_for_type(special_wrap_interface) 93 v8_types.add_includes_for_type(special_wrap_interface)
94 94
95 # Constructors 95 # Constructors
96 constructors = [generate_constructor(interface, constructor) 96 constructors = [generate_constructor(interface, constructor)
97 for constructor in interface.constructors] 97 for constructor in interface.constructors
98 # FIXME: shouldn't put named constructors with constructors
99 # (currently needed for Perl compatibility)
100 # Handle named constructors separately
101 if constructor.name == 'Constructor']
98 generate_constructor_overloads(constructors) 102 generate_constructor_overloads(constructors)
99 if constructors:
100 includes.add('bindings/v8/V8ObjectConstructor.h')
101 103
102 # [CustomConstructor] 104 # [CustomConstructor]
103 has_custom_constructor = 'CustomConstructor' in extended_attributes 105 has_custom_constructor = 'CustomConstructor' in extended_attributes
104 if has_custom_constructor:
105 includes.add('bindings/v8/V8ObjectConstructor.h')
106 106
107 # [EventConstructor] 107 # [EventConstructor]
108 has_event_constructor = 'EventConstructor' in extended_attributes 108 has_event_constructor = 'EventConstructor' in extended_attributes
109 any_type_attributes = [attribute for attribute in interface.attributes 109 any_type_attributes = [attribute for attribute in interface.attributes
110 if attribute.idl_type == 'any'] 110 if attribute.idl_type == 'any']
111 if has_event_constructor: 111 if has_event_constructor:
112 includes.update(['bindings/v8/Dictionary.h', 112 includes.add('bindings/v8/Dictionary.h')
113 'bindings/v8/V8ObjectConstructor.h'])
114 if any_type_attributes: 113 if any_type_attributes:
115 includes.add('bindings/v8/SerializedScriptValue.h') 114 includes.add('bindings/v8/SerializedScriptValue.h')
116 115
116 # [NamedConstructor]
117 if 'NamedConstructor' in extended_attributes:
118 # FIXME: parser should return named constructor separately;
119 # included in constructors (and only name stored in extended attribute)
120 # for Perl compatibility
121 named_constructor = {'name': extended_attributes['NamedConstructor']}
122 includes.add('V8Document.h')
haraken 2013/12/16 08:56:18 Is this needed?
Nils Barth (inactive) 2013/12/16 09:29:45 Nope, removed! It was added for the line: Document
123 else:
124 named_constructor = None
125
126 if (constructors or has_custom_constructor or has_event_constructor or
127 named_constructor):
128 includes.add('bindings/v8/V8ObjectConstructor.h')
129
117 template_contents = { 130 template_contents = {
118 'any_type_attributes': any_type_attributes, 131 'any_type_attributes': any_type_attributes,
119 'conditional_string': conditional_string(interface), # [Conditional] 132 'conditional_string': conditional_string(interface), # [Conditional]
120 'constructors': constructors, 133 'constructors': constructors,
121 'cpp_class': cpp_name(interface), 134 'cpp_class': cpp_name(interface),
122 'generate_visit_dom_wrapper_function': generate_visit_dom_wrapper_functi on, 135 'generate_visit_dom_wrapper_function': generate_visit_dom_wrapper_functi on,
123 'has_custom_constructor': has_custom_constructor, 136 'has_custom_constructor': has_custom_constructor,
124 'has_custom_legacy_call_as_function': has_extended_attribute_value(inter face, 'Custom', 'LegacyCallAsFunction'), # [Custom=LegacyCallAsFunction] 137 'has_custom_legacy_call_as_function': has_extended_attribute_value(inter face, 'Custom', 'LegacyCallAsFunction'), # [Custom=LegacyCallAsFunction]
125 'has_custom_to_v8': has_extended_attribute_value(interface, 'Custom', 'T oV8'), # [Custom=ToV8] 138 'has_custom_to_v8': has_extended_attribute_value(interface, 'Custom', 'T oV8'), # [Custom=ToV8]
126 'has_custom_wrap': has_extended_attribute_value(interface, 'Custom', 'Wr ap'), # [Custom=Wrap] 139 'has_custom_wrap': has_extended_attribute_value(interface, 'Custom', 'Wr ap'), # [Custom=Wrap]
127 'has_event_constructor': has_event_constructor, 140 'has_event_constructor': has_event_constructor,
128 'has_visit_dom_wrapper': ( 141 'has_visit_dom_wrapper': (
129 # [Custom=Wrap], [GenerateVisitDOMWrapper] 142 # [Custom=Wrap], [GenerateVisitDOMWrapper]
130 has_extended_attribute_value(interface, 'Custom', 'VisitDOMWrapper') or 143 has_extended_attribute_value(interface, 'Custom', 'VisitDOMWrapper') or
131 'GenerateVisitDOMWrapper' in extended_attributes), 144 'GenerateVisitDOMWrapper' in extended_attributes),
132 'header_includes': header_includes, 145 'header_includes': header_includes,
133 'interface_length': interface_length(interface, constructors), 146 'interface_length': interface_length(interface, constructors),
134 'interface_name': interface.name, 147 'interface_name': interface.name,
135 'is_active_dom_object': 'ActiveDOMObject' in extended_attributes, # [Ac tiveDOMObject] 148 'is_active_dom_object': 'ActiveDOMObject' in extended_attributes, # [Ac tiveDOMObject]
136 'is_check_security': is_check_security, 149 'is_check_security': is_check_security,
137 'is_constructor_call_with_document': has_extended_attribute_value( 150 'is_constructor_call_with_document': has_extended_attribute_value(
138 interface, 'ConstructorCallWith', 'Document'), # [ConstructorCallWi th=Document] 151 interface, 'ConstructorCallWith', 'Document'), # [ConstructorCallWi th=Document]
139 'is_constructor_call_with_execution_context': has_extended_attribute_val ue( 152 'is_constructor_call_with_execution_context': has_extended_attribute_val ue(
140 interface, 'ConstructorCallWith', 'ExecutionContext'), # [Construct orCallWith=ExeuctionContext] 153 interface, 'ConstructorCallWith', 'ExecutionContext'), # [Construct orCallWith=ExeuctionContext]
141 'is_constructor_raises_exception': extended_attributes.get('RaisesExcept ion') == 'Constructor', # [RaisesException=Constructor] 154 'is_constructor_raises_exception': extended_attributes.get('RaisesExcept ion') == 'Constructor', # [RaisesException=Constructor]
142 'is_dependent_lifetime': 'DependentLifetime' in extended_attributes, # [DependentLifetime] 155 'is_dependent_lifetime': 'DependentLifetime' in extended_attributes, # [DependentLifetime]
143 'measure_as': v8_utilities.measure_as(interface), # [MeasureAs] 156 'measure_as': v8_utilities.measure_as(interface), # [MeasureAs]
157 'named_constructor': named_constructor,
144 'parent_interface': parent_interface, 158 'parent_interface': parent_interface,
145 'runtime_enabled_function': runtime_enabled_function_name(interface), # [RuntimeEnabled] 159 'runtime_enabled_function': runtime_enabled_function_name(interface), # [RuntimeEnabled]
146 'special_wrap_for': special_wrap_for, 160 'special_wrap_for': special_wrap_for,
147 'v8_class': v8_utilities.v8_class_name(interface), 161 'v8_class': v8_utilities.v8_class_name(interface),
148 } 162 }
149 163
150 template_contents.update({ 164 template_contents.update({
151 'constants': [generate_constant(constant) for constant in interface.cons tants], 165 'constants': [generate_constant(constant) for constant in interface.cons tants],
152 'do_not_check_constants': 'DoNotCheckConstants' in extended_attributes, 166 'do_not_check_constants': 'DoNotCheckConstants' in extended_attributes,
153 }) 167 })
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 388
375 389
376 def interface_length(interface, constructors): 390 def interface_length(interface, constructors):
377 # Docs: http://heycam.github.io/webidl/#es-interface-call 391 # Docs: http://heycam.github.io/webidl/#es-interface-call
378 if 'EventConstructor' in interface.extended_attributes: 392 if 'EventConstructor' in interface.extended_attributes:
379 return 1 393 return 1
380 if not constructors: 394 if not constructors:
381 return 0 395 return 0
382 return min(constructor['number_of_required_arguments'] 396 return min(constructor['number_of_required_arguments']
383 for constructor in constructors) 397 for constructor in constructors)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698