OLD | NEW |
1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
2 # coding=utf-8 | 2 # coding=utf-8 |
3 # | 3 # |
4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
6 # met: | 6 # met: |
7 # | 7 # |
8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 import v8_attributes | 43 import v8_attributes |
44 from v8_globals import includes | 44 from v8_globals import includes |
45 import v8_methods | 45 import v8_methods |
46 import v8_types | 46 import v8_types |
47 from v8_types import cpp_ptr_type, cpp_template_type | 47 from v8_types import cpp_ptr_type, cpp_template_type |
48 import v8_utilities | 48 import v8_utilities |
49 from v8_utilities import capitalize, conditional_string, cpp_name, gc_type, has_
extended_attribute_value, runtime_enabled_function_name | 49 from v8_utilities import capitalize, conditional_string, cpp_name, gc_type, has_
extended_attribute_value, runtime_enabled_function_name |
50 | 50 |
51 | 51 |
52 INTERFACE_H_INCLUDES = frozenset([ | 52 INTERFACE_H_INCLUDES = frozenset([ |
53 'bindings/v8/V8Binding.h', | 53 'bindings/core/v8/V8Binding.h', |
54 'bindings/v8/V8DOMWrapper.h', | 54 'bindings/core/v8/V8DOMWrapper.h', |
55 'bindings/v8/WrapperTypeInfo.h', | 55 'bindings/core/v8/WrapperTypeInfo.h', |
56 'platform/heap/Handle.h', | 56 'platform/heap/Handle.h', |
57 ]) | 57 ]) |
58 INTERFACE_CPP_INCLUDES = frozenset([ | 58 INTERFACE_CPP_INCLUDES = frozenset([ |
59 'bindings/v8/ExceptionState.h', | 59 'bindings/core/v8/ExceptionState.h', |
60 'bindings/v8/V8DOMConfiguration.h', | 60 'bindings/core/v8/V8DOMConfiguration.h', |
61 'bindings/v8/V8HiddenValue.h', | 61 'bindings/core/v8/V8HiddenValue.h', |
62 'bindings/v8/V8ObjectConstructor.h', | 62 'bindings/core/v8/V8ObjectConstructor.h', |
63 'core/dom/ContextFeatures.h', | 63 'core/dom/ContextFeatures.h', |
64 'core/dom/Document.h', | 64 'core/dom/Document.h', |
65 'platform/RuntimeEnabledFeatures.h', | 65 'platform/RuntimeEnabledFeatures.h', |
66 'platform/TraceEvent.h', | 66 'platform/TraceEvent.h', |
67 'wtf/GetPtr.h', | 67 'wtf/GetPtr.h', |
68 'wtf/RefPtr.h', | 68 'wtf/RefPtr.h', |
69 ]) | 69 ]) |
70 | 70 |
71 | 71 |
72 def interface_context(interface): | 72 def interface_context(interface): |
73 includes.clear() | 73 includes.clear() |
74 includes.update(INTERFACE_CPP_INCLUDES) | 74 includes.update(INTERFACE_CPP_INCLUDES) |
75 header_includes = set(INTERFACE_H_INCLUDES) | 75 header_includes = set(INTERFACE_H_INCLUDES) |
76 | 76 |
77 parent_interface = interface.parent | 77 parent_interface = interface.parent |
78 if parent_interface: | 78 if parent_interface: |
79 header_includes.update(v8_types.includes_for_interface(parent_interface)
) | 79 header_includes.update(v8_types.includes_for_interface(parent_interface)
) |
80 extended_attributes = interface.extended_attributes | 80 extended_attributes = interface.extended_attributes |
81 | 81 |
82 is_audio_buffer = inherits_interface(interface.name, 'AudioBuffer') | 82 is_audio_buffer = inherits_interface(interface.name, 'AudioBuffer') |
83 if is_audio_buffer: | 83 if is_audio_buffer: |
84 includes.add('modules/webaudio/AudioBuffer.h') | 84 includes.add('modules/webaudio/AudioBuffer.h') |
85 | 85 |
86 is_document = inherits_interface(interface.name, 'Document') | 86 is_document = inherits_interface(interface.name, 'Document') |
87 if is_document: | 87 if is_document: |
88 includes.update(['bindings/v8/ScriptController.h', | 88 includes.update(['bindings/core/v8/ScriptController.h', |
89 'bindings/v8/V8WindowShell.h', | 89 'bindings/core/v8/V8WindowShell.h', |
90 'core/frame/LocalFrame.h']) | 90 'core/frame/LocalFrame.h']) |
91 | 91 |
92 # [ActiveDOMObject] | 92 # [ActiveDOMObject] |
93 is_active_dom_object = 'ActiveDOMObject' in extended_attributes | 93 is_active_dom_object = 'ActiveDOMObject' in extended_attributes |
94 | 94 |
95 # [CheckSecurity] | 95 # [CheckSecurity] |
96 is_check_security = 'CheckSecurity' in extended_attributes | 96 is_check_security = 'CheckSecurity' in extended_attributes |
97 if is_check_security: | 97 if is_check_security: |
98 includes.add('bindings/v8/BindingSecurity.h') | 98 includes.add('bindings/core/v8/BindingSecurity.h') |
99 | 99 |
100 # [DependentLifetime] | 100 # [DependentLifetime] |
101 is_dependent_lifetime = 'DependentLifetime' in extended_attributes | 101 is_dependent_lifetime = 'DependentLifetime' in extended_attributes |
102 | 102 |
103 # [MeasureAs] | 103 # [MeasureAs] |
104 is_measure_as = 'MeasureAs' in extended_attributes | 104 is_measure_as = 'MeasureAs' in extended_attributes |
105 if is_measure_as: | 105 if is_measure_as: |
106 includes.add('core/frame/UseCounter.h') | 106 includes.add('core/frame/UseCounter.h') |
107 | 107 |
108 # [SetWrapperReferenceFrom] | 108 # [SetWrapperReferenceFrom] |
109 reachable_node_function = extended_attributes.get('SetWrapperReferenceFrom') | 109 reachable_node_function = extended_attributes.get('SetWrapperReferenceFrom') |
110 if reachable_node_function: | 110 if reachable_node_function: |
111 includes.update(['bindings/v8/V8GCController.h', | 111 includes.update(['bindings/core/v8/V8GCController.h', |
112 'core/dom/Element.h']) | 112 'core/dom/Element.h']) |
113 | 113 |
114 # [SetWrapperReferenceTo] | 114 # [SetWrapperReferenceTo] |
115 set_wrapper_reference_to_list = [{ | 115 set_wrapper_reference_to_list = [{ |
116 'name': argument.name, | 116 'name': argument.name, |
117 # FIXME: properly should be: | 117 # FIXME: properly should be: |
118 # 'cpp_type': argument.idl_type.cpp_type_args(raw_type=True), | 118 # 'cpp_type': argument.idl_type.cpp_type_args(raw_type=True), |
119 # (if type is non-wrapper type like NodeFilter, normally RefPtr) | 119 # (if type is non-wrapper type like NodeFilter, normally RefPtr) |
120 # Raw pointers faster though, and NodeFilter hacky anyway. | 120 # Raw pointers faster though, and NodeFilter hacky anyway. |
121 'cpp_type': argument.idl_type.implemented_as + '*', | 121 'cpp_type': argument.idl_type.implemented_as + '*', |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 custom_constructors = [{ # Only needed for computing interface length | 190 custom_constructors = [{ # Only needed for computing interface length |
191 'number_of_required_arguments': | 191 'number_of_required_arguments': |
192 number_of_required_arguments(constructor), | 192 number_of_required_arguments(constructor), |
193 } for constructor in interface.custom_constructors] | 193 } for constructor in interface.custom_constructors] |
194 | 194 |
195 # [EventConstructor] | 195 # [EventConstructor] |
196 has_event_constructor = 'EventConstructor' in extended_attributes | 196 has_event_constructor = 'EventConstructor' in extended_attributes |
197 any_type_attributes = [attribute for attribute in interface.attributes | 197 any_type_attributes = [attribute for attribute in interface.attributes |
198 if attribute.idl_type.name == 'Any'] | 198 if attribute.idl_type.name == 'Any'] |
199 if has_event_constructor: | 199 if has_event_constructor: |
200 includes.add('bindings/v8/Dictionary.h') | 200 includes.add('bindings/core/v8/Dictionary.h') |
201 if any_type_attributes: | 201 if any_type_attributes: |
202 includes.add('bindings/v8/SerializedScriptValue.h') | 202 includes.add('bindings/core/v8/SerializedScriptValue.h') |
203 | 203 |
204 # [NamedConstructor] | 204 # [NamedConstructor] |
205 named_constructor = named_constructor_context(interface) | 205 named_constructor = named_constructor_context(interface) |
206 | 206 |
207 if (constructors or custom_constructors or has_event_constructor or | 207 if (constructors or custom_constructors or has_event_constructor or |
208 named_constructor): | 208 named_constructor): |
209 includes.add('bindings/v8/V8ObjectConstructor.h') | 209 includes.add('bindings/core/v8/V8ObjectConstructor.h') |
210 includes.add('core/frame/LocalDOMWindow.h') | 210 includes.add('core/frame/LocalDOMWindow.h') |
211 | 211 |
212 context.update({ | 212 context.update({ |
213 'any_type_attributes': any_type_attributes, | 213 'any_type_attributes': any_type_attributes, |
214 'constructors': constructors, | 214 'constructors': constructors, |
215 'has_custom_constructor': bool(custom_constructors), | 215 'has_custom_constructor': bool(custom_constructors), |
216 'has_event_constructor': has_event_constructor, | 216 'has_event_constructor': has_event_constructor, |
217 'interface_length': | 217 'interface_length': |
218 interface_length(interface, constructors + custom_constructors), | 218 interface_length(interface, constructors + custom_constructors), |
219 'is_constructor_call_with_document': has_extended_attribute_value( | 219 'is_constructor_call_with_document': has_extended_attribute_value( |
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 deleter = next( | 1091 deleter = next( |
1092 method | 1092 method |
1093 for method in interface.operations | 1093 for method in interface.operations |
1094 if ('deleter' in method.specials and | 1094 if ('deleter' in method.specials and |
1095 len(method.arguments) == 1 and | 1095 len(method.arguments) == 1 and |
1096 str(method.arguments[0].idl_type) == 'DOMString')) | 1096 str(method.arguments[0].idl_type) == 'DOMString')) |
1097 except StopIteration: | 1097 except StopIteration: |
1098 return None | 1098 return None |
1099 | 1099 |
1100 return property_deleter(deleter) | 1100 return property_deleter(deleter) |
OLD | NEW |