Index: Source/bindings/scripts/v8_includes.py |
diff --git a/Source/bindings/scripts/v8_includes.py b/Source/bindings/scripts/v8_includes.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6c7b7b349f766c4d523a18e24bec4e806be15a3a |
--- /dev/null |
+++ b/Source/bindings/scripts/v8_includes.py |
@@ -0,0 +1,131 @@ |
+# Copyright (C) 2013 Google Inc. All rights reserved. |
+# |
+# Redistribution and use in source and binary forms, with or without |
+# modification, are permitted provided that the following conditions are |
+# met: |
+# |
+# * Redistributions of source code must retain the above copyright |
+# notice, this list of conditions and the following disclaimer. |
+# * Redistributions in binary form must reproduce the above |
+# copyright notice, this list of conditions and the following disclaimer |
+# in the documentation and/or other materials provided with the |
+# distribution. |
+# * Neither the name of Google Inc. nor the names of its |
+# contributors may be used to endorse or promote products derived from |
+# this software without specific prior written permission. |
+# |
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
+# 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+ |
+import posixpath |
+ |
+from v8_types import get_array_or_sequence_type, primitive_type |
+ |
+# WIP |
+from code_generator_idl_reader import idl_file_rel_dir_posix |
+from v8_types import is_callback_function_type, is_typed_array_type, skip_include_header |
+ |
+CALLBACK_INTERFACE_H_INCLUDES = set([ |
+ 'bindings/v8/ActiveDOMCallback.h', |
+ 'bindings/v8/DOMWrapperWorld.h', |
+ 'bindings/v8/ScopedPersistent.h', |
+]) |
+CALLBACK_INTERFACE_CPP_INCLUDES = set([ |
+ 'core/dom/ScriptExecutionContext.h', |
+ 'bindings/v8/V8Binding.h', |
+ 'bindings/v8/V8Callback.h', |
+ 'wtf/Assertions.h', |
+]) |
+ |
+INTERFACE_H_INCLUDES = set([ |
+ 'bindings/v8/V8Binding.h', |
+ 'bindings/v8/V8DOMWrapper.h', |
+ 'bindings/v8/WrapperTypeInfo.h', |
+]) |
+INTERFACE_CPP_INCLUDES = set([ |
+ 'RuntimeEnabledFeatures.h', |
+ 'bindings/v8/ScriptController.h', |
+ 'bindings/v8/V8Binding.h', |
+ 'bindings/v8/V8DOMWrapper.h', |
+ 'bindings/v8/V8DOMConfiguration.h', |
+ 'core/dom/ContextFeatures.h', |
+ 'core/dom/Document.h', |
+ 'core/page/Frame.h', |
+ 'core/platform/chromium/TraceEvent.h', |
+ 'wtf/UnusedParam.h', |
+]) |
+ |
+ |
+def includes_for_type(data_type): |
+ if primitive_type(data_type) or data_type == 'DOMString': |
+ return set() |
+ array_or_sequence_type = get_array_or_sequence_type(data_type) |
+ if array_or_sequence_type: |
+ return includes_for_type(array_or_sequence_type) |
+ return set(['V8%s.h' % data_type]) |
+ |
+ |
+def includes_for_cpp_class(class_name, relative_dir_posix): |
+ return set([posixpath.join('bindings', relative_dir_posix, class_name + '.h')]) |
+ |
+ |
+def includes_for_operation(operation): |
+ includes = includes_for_type(operation.data_type) |
+ for parameter in operation.arguments: |
+ includes |= includes_for_type(parameter.data_type) |
+ return includes |
+ |
+ |
+################################################################################ |
+# WIP |
+# FIXME: below use lists, not sets |
+################################################################################ |
+ |
+ |
+def get_includes_for_type(data_type): |
+ # print 'get_includes_for_type', data_type |
+ if skip_include_header(data_type): |
+ return [] |
+ if data_type in ['EventListener', 'EventHandler']: |
+ return ['core/dom/EventListener.h'] |
+ if data_type == 'SerializedScriptValue': |
+ return ['bindings/v8/SerializedScriptValue.h'] |
+ if data_type == 'any' or is_callback_function_type(data_type): |
+ return ['bindings/v8/ScriptValue.h'] |
+ return ['V8%s.h' % data_type] |
+ |
+ |
+def get_includes_for_parameter(parameter): |
+ array_or_sequence_type = get_array_or_sequence_type(parameter.data_type) |
+ if not array_or_sequence_type: |
+ return get_includes_for_type(parameter.data_type) |
+ if is_ref_ptr_type(array_or_sequence_type): |
+ return get_includes_for_type(array_or_sequence_type) |
+ return [] |
+ |
+ |
+def get_includes_for_operation(operation): |
+ includes = get_includes_for_type(operation.data_type) |
+ for parameter in operation.arguments: |
+ includes += get_includes_for_parameter(parameter) |
+ return includes |
+ |
+ |
+def header_files_for_interface(interface_name, cpp_class_name): |
+ """HeaderFilesForInterface in perl""" |
+# print '[header_files_for_interface]', interface_name, cpp_class_name |
+ if is_typed_array_type(interface_name): |
+ return ['wtf/%s.h' % interface_name] |
+ elif not skip_include_header(interface_name): |
+ relative_dir_posix = idl_file_rel_dir_posix(interface_name) |
+ return list(includes_for_cpp_class(cpp_class_name, relative_dir_posix)) |
+ return [] |