OLD | NEW |
(Empty) | |
| 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
| 2 # |
| 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are |
| 5 # met: |
| 6 # |
| 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer |
| 11 # in the documentation and/or other materials provided with the |
| 12 # distribution. |
| 13 # * Neither the name of Google Inc. nor the names of its |
| 14 # contributors may be used to endorse or promote products derived from |
| 15 # this software without specific prior written permission. |
| 16 # |
| 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 18 # 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 |
| 29 import posixpath |
| 30 |
| 31 from v8_types import get_array_or_sequence_type, primitive_type |
| 32 |
| 33 # WIP |
| 34 from code_generator_idl_reader import idl_file_rel_dir_posix |
| 35 from v8_types import is_callback_function_type, is_typed_array_type, skip_includ
e_header |
| 36 |
| 37 CALLBACK_INTERFACE_H_INCLUDES = set([ |
| 38 'bindings/v8/ActiveDOMCallback.h', |
| 39 'bindings/v8/DOMWrapperWorld.h', |
| 40 'bindings/v8/ScopedPersistent.h', |
| 41 ]) |
| 42 CALLBACK_INTERFACE_CPP_INCLUDES = set([ |
| 43 'core/dom/ScriptExecutionContext.h', |
| 44 'bindings/v8/V8Binding.h', |
| 45 'bindings/v8/V8Callback.h', |
| 46 'wtf/Assertions.h', |
| 47 ]) |
| 48 |
| 49 INTERFACE_H_INCLUDES = set([ |
| 50 'bindings/v8/V8Binding.h', |
| 51 'bindings/v8/V8DOMWrapper.h', |
| 52 'bindings/v8/WrapperTypeInfo.h', |
| 53 ]) |
| 54 INTERFACE_CPP_INCLUDES = set([ |
| 55 'RuntimeEnabledFeatures.h', |
| 56 'bindings/v8/ScriptController.h', |
| 57 'bindings/v8/V8Binding.h', |
| 58 'bindings/v8/V8DOMWrapper.h', |
| 59 'bindings/v8/V8DOMConfiguration.h', |
| 60 'core/dom/ContextFeatures.h', |
| 61 'core/dom/Document.h', |
| 62 'core/page/Frame.h', |
| 63 'core/platform/chromium/TraceEvent.h', |
| 64 'wtf/UnusedParam.h', |
| 65 ]) |
| 66 |
| 67 |
| 68 def includes_for_type(data_type): |
| 69 if primitive_type(data_type) or data_type == 'DOMString': |
| 70 return set() |
| 71 array_or_sequence_type = get_array_or_sequence_type(data_type) |
| 72 if array_or_sequence_type: |
| 73 return includes_for_type(array_or_sequence_type) |
| 74 return set(['V8%s.h' % data_type]) |
| 75 |
| 76 |
| 77 def includes_for_cpp_class(class_name, relative_dir_posix): |
| 78 return set([posixpath.join('bindings', relative_dir_posix, class_name + '.h'
)]) |
| 79 |
| 80 |
| 81 def includes_for_operation(operation): |
| 82 includes = includes_for_type(operation.data_type) |
| 83 for parameter in operation.arguments: |
| 84 includes |= includes_for_type(parameter.data_type) |
| 85 return includes |
| 86 |
| 87 |
| 88 ################################################################################ |
| 89 # WIP |
| 90 # FIXME: below use lists, not sets |
| 91 ################################################################################ |
| 92 |
| 93 |
| 94 def get_includes_for_type(data_type): |
| 95 # print 'get_includes_for_type', data_type |
| 96 if skip_include_header(data_type): |
| 97 return [] |
| 98 if data_type in ['EventListener', 'EventHandler']: |
| 99 return ['core/dom/EventListener.h'] |
| 100 if data_type == 'SerializedScriptValue': |
| 101 return ['bindings/v8/SerializedScriptValue.h'] |
| 102 if data_type == 'any' or is_callback_function_type(data_type): |
| 103 return ['bindings/v8/ScriptValue.h'] |
| 104 return ['V8%s.h' % data_type] |
| 105 |
| 106 |
| 107 def get_includes_for_parameter(parameter): |
| 108 array_or_sequence_type = get_array_or_sequence_type(parameter.data_type) |
| 109 if not array_or_sequence_type: |
| 110 return get_includes_for_type(parameter.data_type) |
| 111 if is_ref_ptr_type(array_or_sequence_type): |
| 112 return get_includes_for_type(array_or_sequence_type) |
| 113 return [] |
| 114 |
| 115 |
| 116 def get_includes_for_operation(operation): |
| 117 includes = get_includes_for_type(operation.data_type) |
| 118 for parameter in operation.arguments: |
| 119 includes += get_includes_for_parameter(parameter) |
| 120 return includes |
| 121 |
| 122 |
| 123 def header_files_for_interface(interface_name, cpp_class_name): |
| 124 """HeaderFilesForInterface in perl""" |
| 125 # print '[header_files_for_interface]', interface_name, cpp_class_name |
| 126 if is_typed_array_type(interface_name): |
| 127 return ['wtf/%s.h' % interface_name] |
| 128 elif not skip_include_header(interface_name): |
| 129 relative_dir_posix = idl_file_rel_dir_posix(interface_name) |
| 130 return list(includes_for_cpp_class(cpp_class_name, relative_dir_posix)) |
| 131 return [] |
OLD | NEW |