| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 generate_visit_dom_wrapper_function = extended_attributes.get('GenerateVisit
DOMWrapper') | 83 generate_visit_dom_wrapper_function = extended_attributes.get('GenerateVisit
DOMWrapper') |
| 84 if generate_visit_dom_wrapper_function: | 84 if generate_visit_dom_wrapper_function: |
| 85 includes.update(['bindings/v8/V8GCController.h', | 85 includes.update(['bindings/v8/V8GCController.h', |
| 86 'core/dom/Element.h']) | 86 'core/dom/Element.h']) |
| 87 | 87 |
| 88 # [MeasureAs] | 88 # [MeasureAs] |
| 89 is_measure_as = 'MeasureAs' in extended_attributes | 89 is_measure_as = 'MeasureAs' in extended_attributes |
| 90 if is_measure_as: | 90 if is_measure_as: |
| 91 includes.add('core/frame/UseCounter.h') | 91 includes.add('core/frame/UseCounter.h') |
| 92 | 92 |
| 93 # [RaisesException] | 93 # [RaisesException=Constructor] |
| 94 is_constructor_raises_exception = extended_attributes.get('RaisesException')
== 'Constructor' | 94 is_constructor_raises_exception = extended_attributes.get('RaisesException')
== 'Constructor' |
| 95 if is_constructor_raises_exception: | 95 if is_constructor_raises_exception: |
| 96 includes.add('bindings/v8/ExceptionState.h') | 96 includes.add('bindings/v8/ExceptionState.h') |
| 97 | 97 |
| 98 # [SpecialWrapFor] | 98 # [SpecialWrapFor] |
| 99 if 'SpecialWrapFor' in extended_attributes: | 99 if 'SpecialWrapFor' in extended_attributes: |
| 100 special_wrap_for = extended_attributes['SpecialWrapFor'].split('|') | 100 special_wrap_for = extended_attributes['SpecialWrapFor'].split('|') |
| 101 else: | 101 else: |
| 102 special_wrap_for = [] | 102 special_wrap_for = [] |
| 103 for special_wrap_interface in special_wrap_for: | 103 for special_wrap_interface in special_wrap_for: |
| 104 v8_types.add_includes_for_type(special_wrap_interface) | 104 v8_types.add_includes_for_type(special_wrap_interface) |
| 105 | 105 |
| 106 # Constructors | 106 # Constructors |
| 107 # [Constructor] | 107 # [Constructor] |
| 108 has_constructor = 'Constructor' in extended_attributes | 108 has_constructor = 'Constructor' in extended_attributes |
| 109 if has_constructor: | 109 if has_constructor: |
| 110 includes.add('bindings/v8/V8ObjectConstructor.h') | 110 includes.add('bindings/v8/V8ObjectConstructor.h') |
| 111 | 111 |
| 112 # [EventConstructor] | 112 # [EventConstructor] |
| 113 has_event_constructor = 'EventConstructor' in extended_attributes | 113 has_event_constructor = 'EventConstructor' in extended_attributes |
| 114 if has_event_constructor: | 114 if has_event_constructor: |
| 115 includes.update(['bindings/v8/Dictionary.h', | 115 includes.update(['bindings/v8/Dictionary.h', |
| 116 'bindings/v8/V8ObjectConstructor.h']) | 116 'bindings/v8/V8ObjectConstructor.h']) |
| 117 | 117 |
| 118 template_contents = { | 118 template_contents = { |
| 119 'conditional_string': conditional_string(interface), # [Conditional] | 119 'conditional_string': conditional_string(interface), # [Conditional] |
| 120 'constructor_arguments': ['exceptionState'] if is_constructor_raises_exc
eption else [], # FIXME: arguments are a complex function in general | 120 'constructor_arguments': constructor_arguments(interface), |
| 121 'cpp_class': cpp_name(interface), | 121 'cpp_class': cpp_name(interface), |
| 122 'generate_visit_dom_wrapper_function': generate_visit_dom_wrapper_functi
on, | 122 'generate_visit_dom_wrapper_function': generate_visit_dom_wrapper_functi
on, |
| 123 'has_constructor': has_constructor, | 123 'has_constructor': has_constructor, |
| 124 'has_custom_legacy_call_as_function': has_extended_attribute_value(inter
face, 'Custom', 'LegacyCallAsFunction'), # [Custom=LegacyCallAsFunction] | 124 '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] | 125 '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] | 126 'has_custom_wrap': has_extended_attribute_value(interface, 'Custom', 'Wr
ap'), # [Custom=Wrap] |
| 127 'has_event_constructor': has_event_constructor, | 127 'has_event_constructor': has_event_constructor, |
| 128 'has_visit_dom_wrapper': ( | 128 'has_visit_dom_wrapper': ( |
| 129 # [Custom=Wrap], [GenerateVisitDOMWrapper] | 129 # [Custom=Wrap], [GenerateVisitDOMWrapper] |
| 130 has_extended_attribute_value(interface, 'Custom', 'VisitDOMWrapper')
or | 130 has_extended_attribute_value(interface, 'Custom', 'VisitDOMWrapper')
or |
| 131 'GenerateVisitDOMWrapper' in extended_attributes), | 131 'GenerateVisitDOMWrapper' in extended_attributes), |
| 132 'header_includes': header_includes, | 132 'header_includes': header_includes, |
| 133 'interface_name': interface.name, | 133 'interface_name': interface.name, |
| 134 'is_active_dom_object': 'ActiveDOMObject' in extended_attributes, # [Ac
tiveDOMObject] | 134 'is_active_dom_object': 'ActiveDOMObject' in extended_attributes, # [Ac
tiveDOMObject] |
| 135 'is_check_security': is_check_security, | 135 'is_check_security': is_check_security, |
| 136 'is_constructor_call_with_document': has_extended_attribute_value( |
| 137 interface, 'ConstructorCallWith', 'Document'), # [ConstructorCallWi
th=Document] |
| 138 'is_constructor_call_with_execution_context': has_extended_attribute_val
ue( |
| 139 interface, 'ConstructorCallWith', 'ExecutionContext'), # [Construct
orCallWith=ExeuctionContext] |
| 136 'is_constructor_raises_exception': is_constructor_raises_exception, | 140 'is_constructor_raises_exception': is_constructor_raises_exception, |
| 137 'is_dependent_lifetime': 'DependentLifetime' in extended_attributes, #
[DependentLifetime] | 141 'is_dependent_lifetime': 'DependentLifetime' in extended_attributes, #
[DependentLifetime] |
| 138 'length': 1 if has_event_constructor else 0, # FIXME: more complex in g
eneral, see discussion of length in http://heycam.github.io/webidl/#es-interface
-call | 142 'length': 1 if has_event_constructor else 0, # FIXME: more complex in g
eneral, see discussion of length in http://heycam.github.io/webidl/#es-interface
-call |
| 139 'measure_as': v8_utilities.measure_as(interface), # [MeasureAs] | 143 'measure_as': v8_utilities.measure_as(interface), # [MeasureAs] |
| 140 'parent_interface': parent_interface, | 144 'parent_interface': parent_interface, |
| 141 'runtime_enabled_function': runtime_enabled_function_name(interface), #
[RuntimeEnabled] | 145 'runtime_enabled_function': runtime_enabled_function_name(interface), #
[RuntimeEnabled] |
| 142 'special_wrap_for': special_wrap_for, | 146 'special_wrap_for': special_wrap_for, |
| 143 'v8_class': v8_utilities.v8_class_name(interface), | 147 'v8_class': v8_utilities.v8_class_name(interface), |
| 144 } | 148 } |
| 145 | 149 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 '%s->IsString()' % cpp_value, | 303 '%s->IsString()' % cpp_value, |
| 300 '%s->IsObject()' % cpp_value]) | 304 '%s->IsObject()' % cpp_value]) |
| 301 if v8_types.array_or_sequence_type(idl_type): | 305 if v8_types.array_or_sequence_type(idl_type): |
| 302 return '%s->IsArray()' % cpp_value | 306 return '%s->IsArray()' % cpp_value |
| 303 if v8_types.is_wrapper_type(idl_type): | 307 if v8_types.is_wrapper_type(idl_type): |
| 304 type_check = 'V8{idl_type}::hasInstance({cpp_value}, info.GetIsolate(),
worldType(info.GetIsolate()))'.format(idl_type=idl_type, cpp_value=cpp_value) | 308 type_check = 'V8{idl_type}::hasInstance({cpp_value}, info.GetIsolate(),
worldType(info.GetIsolate()))'.format(idl_type=idl_type, cpp_value=cpp_value) |
| 305 if argument['is_nullable']: | 309 if argument['is_nullable']: |
| 306 type_check = ' || '.join(['%s->IsNull()' % cpp_value, type_check]) | 310 type_check = ' || '.join(['%s->IsNull()' % cpp_value, type_check]) |
| 307 return type_check | 311 return type_check |
| 308 return None | 312 return None |
| 313 |
| 314 |
| 315 def constructor_arguments(interface): |
| 316 arguments = [] |
| 317 # [ConstructorCallWith=ExecutionContext] |
| 318 if has_extended_attribute_value(interface, 'ConstructorCallWith', 'Execution
Context'): |
| 319 arguments.append('context') |
| 320 # [ConstructorCallWith=Document] |
| 321 if has_extended_attribute_value(interface, 'ConstructorCallWith', 'Document'
): |
| 322 arguments.append('document') |
| 323 # FIXME: actual arguments! |
| 324 # [RaisesException=Constructor] |
| 325 if interface.extended_attributes.get('RaisesException') == 'Constructor': |
| 326 arguments.append('exceptionState') |
| 327 return arguments |
| OLD | NEW |