| OLD | NEW |
| 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 Loading... |
| 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 else: |
| 123 named_constructor = None |
| 124 |
| 125 if (constructors or has_custom_constructor or has_event_constructor or |
| 126 named_constructor): |
| 127 includes.add('bindings/v8/V8ObjectConstructor.h') |
| 128 |
| 117 template_contents = { | 129 template_contents = { |
| 118 'any_type_attributes': any_type_attributes, | 130 'any_type_attributes': any_type_attributes, |
| 119 'conditional_string': conditional_string(interface), # [Conditional] | 131 'conditional_string': conditional_string(interface), # [Conditional] |
| 120 'constructors': constructors, | 132 'constructors': constructors, |
| 121 'cpp_class': cpp_name(interface), | 133 'cpp_class': cpp_name(interface), |
| 122 'generate_visit_dom_wrapper_function': generate_visit_dom_wrapper_functi
on, | 134 'generate_visit_dom_wrapper_function': generate_visit_dom_wrapper_functi
on, |
| 123 'has_custom_constructor': has_custom_constructor, | 135 'has_custom_constructor': has_custom_constructor, |
| 124 'has_custom_legacy_call_as_function': has_extended_attribute_value(inter
face, 'Custom', 'LegacyCallAsFunction'), # [Custom=LegacyCallAsFunction] | 136 '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] | 137 '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] | 138 'has_custom_wrap': has_extended_attribute_value(interface, 'Custom', 'Wr
ap'), # [Custom=Wrap] |
| 127 'has_event_constructor': has_event_constructor, | 139 'has_event_constructor': has_event_constructor, |
| 128 'has_visit_dom_wrapper': ( | 140 'has_visit_dom_wrapper': ( |
| 129 # [Custom=Wrap], [GenerateVisitDOMWrapper] | 141 # [Custom=Wrap], [GenerateVisitDOMWrapper] |
| 130 has_extended_attribute_value(interface, 'Custom', 'VisitDOMWrapper')
or | 142 has_extended_attribute_value(interface, 'Custom', 'VisitDOMWrapper')
or |
| 131 'GenerateVisitDOMWrapper' in extended_attributes), | 143 'GenerateVisitDOMWrapper' in extended_attributes), |
| 132 'header_includes': header_includes, | 144 'header_includes': header_includes, |
| 133 'interface_length': interface_length(interface, constructors), | 145 'interface_length': interface_length(interface, constructors), |
| 134 'interface_name': interface.name, | 146 'interface_name': interface.name, |
| 135 'is_active_dom_object': 'ActiveDOMObject' in extended_attributes, # [Ac
tiveDOMObject] | 147 'is_active_dom_object': 'ActiveDOMObject' in extended_attributes, # [Ac
tiveDOMObject] |
| 136 'is_check_security': is_check_security, | 148 'is_check_security': is_check_security, |
| 137 'is_constructor_call_with_document': has_extended_attribute_value( | 149 'is_constructor_call_with_document': has_extended_attribute_value( |
| 138 interface, 'ConstructorCallWith', 'Document'), # [ConstructorCallWi
th=Document] | 150 interface, 'ConstructorCallWith', 'Document'), # [ConstructorCallWi
th=Document] |
| 139 'is_constructor_call_with_execution_context': has_extended_attribute_val
ue( | 151 'is_constructor_call_with_execution_context': has_extended_attribute_val
ue( |
| 140 interface, 'ConstructorCallWith', 'ExecutionContext'), # [Construct
orCallWith=ExeuctionContext] | 152 interface, 'ConstructorCallWith', 'ExecutionContext'), # [Construct
orCallWith=ExeuctionContext] |
| 141 'is_constructor_raises_exception': extended_attributes.get('RaisesExcept
ion') == 'Constructor', # [RaisesException=Constructor] | 153 'is_constructor_raises_exception': extended_attributes.get('RaisesExcept
ion') == 'Constructor', # [RaisesException=Constructor] |
| 142 'is_dependent_lifetime': 'DependentLifetime' in extended_attributes, #
[DependentLifetime] | 154 'is_dependent_lifetime': 'DependentLifetime' in extended_attributes, #
[DependentLifetime] |
| 143 'measure_as': v8_utilities.measure_as(interface), # [MeasureAs] | 155 'measure_as': v8_utilities.measure_as(interface), # [MeasureAs] |
| 156 'named_constructor': named_constructor, |
| 144 'parent_interface': parent_interface, | 157 'parent_interface': parent_interface, |
| 145 'runtime_enabled_function': runtime_enabled_function_name(interface), #
[RuntimeEnabled] | 158 'runtime_enabled_function': runtime_enabled_function_name(interface), #
[RuntimeEnabled] |
| 146 'special_wrap_for': special_wrap_for, | 159 'special_wrap_for': special_wrap_for, |
| 147 'v8_class': v8_utilities.v8_class_name(interface), | 160 'v8_class': v8_utilities.v8_class_name(interface), |
| 148 } | 161 } |
| 149 | 162 |
| 150 template_contents.update({ | 163 template_contents.update({ |
| 151 'constants': [generate_constant(constant) for constant in interface.cons
tants], | 164 'constants': [generate_constant(constant) for constant in interface.cons
tants], |
| 152 'do_not_check_constants': 'DoNotCheckConstants' in extended_attributes, | 165 'do_not_check_constants': 'DoNotCheckConstants' in extended_attributes, |
| 153 }) | 166 }) |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 | 387 |
| 375 | 388 |
| 376 def interface_length(interface, constructors): | 389 def interface_length(interface, constructors): |
| 377 # Docs: http://heycam.github.io/webidl/#es-interface-call | 390 # Docs: http://heycam.github.io/webidl/#es-interface-call |
| 378 if 'EventConstructor' in interface.extended_attributes: | 391 if 'EventConstructor' in interface.extended_attributes: |
| 379 return 1 | 392 return 1 |
| 380 if not constructors: | 393 if not constructors: |
| 381 return 0 | 394 return 0 |
| 382 return min(constructor['number_of_required_arguments'] | 395 return min(constructor['number_of_required_arguments'] |
| 383 for constructor in constructors) | 396 for constructor in constructors) |
| OLD | NEW |