WebKit Bugzilla
Attachment 348154 Details for
Bug 156674
: Build tools should work when the /usr/bin/python is python3
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-156674-20180827115109.patch (text/plain), 279.04 KB, created by
Mike Gorse
on 2018-08-27 09:51:12 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Mike Gorse
Created:
2018-08-27 09:51:12 PDT
Size:
279.04 KB
patch
obsolete
>Subversion Revision: 235367 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 2d2ac0bfa067180707e0a5bb5aae74ef2eb3ae60..7e5b2f21b381bc098d72b57d151414123c85179e 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,237 @@ >+2018-08-27 Mike Gorse <mgorse@suse.com> >+ >+ Build tools should work when the /usr/bin/python is python3 >+ https://bugs.webkit.org/show_bug.cgi?id=156674 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * CMakeLists.txt: builtins -> wkbuiltins >+ * Scripts/cssmin.py: >+ * Scripts/generate-js-builtins.py: >+ (doopen): >+ (generate_bindings_for_builtins_files): >+ * Scripts/generateIntlCanonicalizeLanguage.py: >+ * Scripts/generateYarrUnicodePropertyTables.py: >+ * Scripts/hasher.py: >+ (stringHash): >+ * Scripts/jsmin.py: >+ (JavascriptMinify.minify.write): >+ (JavascriptMinify): >+ (JavascriptMinify.minify): >+ * Scripts/make-js-file-arrays.py: >+ (chunk): >+ (main): >+ * Scripts/wkbuiltins/__init__.py: Renamed from Source/JavaScriptCore/Scripts/builtins/__init__.py. >+ * Scripts/wkbuiltins/builtins.py: Renamed from Source/JavaScriptCore/Scripts/builtins/builtins.py. >+ * Scripts/wkbuiltins/builtins_generate_combined_header.py: Renamed from Source/JavaScriptCore/Scripts/builtins/builtins_generate_combined_header.py. >+ (BuiltinsCombinedHeaderGenerator): >+ (BuiltinsCombinedHeaderGenerator.__init__): >+ (BuiltinsCombinedHeaderGenerator.output_filename): >+ (BuiltinsCombinedHeaderGenerator.generate_output): >+ (BuiltinsCombinedHeaderGenerator.generate_forward_declarations): >+ (FunctionExecutable): >+ (VM): >+ (ConstructAbility): >+ (generate_section_for_object): >+ (generate_externs_for_object): >+ (generate_macros_for_object): >+ (generate_section_for_code_table_macro): >+ (generate_section_for_code_name_macro): >+ (generate_section_for_global_private_code_name_macro): >+ * Scripts/wkbuiltins/builtins_generate_combined_implementation.py: Renamed from Source/JavaScriptCore/Scripts/builtins/builtins_generate_combined_implementation.py. >+ (BuiltinsCombinedImplementationGenerator): >+ (BuiltinsCombinedImplementationGenerator.__init__): >+ (BuiltinsCombinedImplementationGenerator.output_filename): >+ (BuiltinsCombinedImplementationGenerator.generate_output): >+ (BuiltinsCombinedImplementationGenerator.generate_secondary_header_includes): >+ * Scripts/wkbuiltins/builtins_generate_internals_wrapper_header.py: Renamed from Source/JavaScriptCore/Scripts/builtins/builtins_generate_internals_wrapper_header.py. >+ (BuiltinsInternalsWrapperHeaderGenerator): >+ (BuiltinsInternalsWrapperHeaderGenerator.__init__): >+ (BuiltinsInternalsWrapperHeaderGenerator.output_filename): >+ (BuiltinsInternalsWrapperHeaderGenerator.generate_output): >+ (BuiltinsInternalsWrapperHeaderGenerator.generate_secondary_header_includes): >+ (BuiltinsInternalsWrapperHeaderGenerator.generate_section_for_object): >+ (BuiltinsInternalsWrapperHeaderGenerator.generate_section_for_object.JSDOMGlobalObject): >+ (BuiltinsInternalsWrapperHeaderGenerator.accessor_name): >+ (BuiltinsInternalsWrapperHeaderGenerator.member_name): >+ (BuiltinsInternalsWrapperHeaderGenerator.member_type): >+ (BuiltinsInternalsWrapperHeaderGenerator.generate_methods): >+ * Scripts/wkbuiltins/builtins_generate_internals_wrapper_implementation.py: Renamed from Source/JavaScriptCore/Scripts/builtins/builtins_generate_internals_wrapper_implementation.py. >+ (BuiltinsInternalsWrapperImplementationGenerator): >+ (BuiltinsInternalsWrapperImplementationGenerator.__init__): >+ (BuiltinsInternalsWrapperImplementationGenerator.output_filename): >+ (BuiltinsInternalsWrapperImplementationGenerator.generate_output): >+ (BuiltinsInternalsWrapperImplementationGenerator.generate_secondary_header_includes): >+ (BuiltinsInternalsWrapperImplementationGenerator.generate_section_for_object): >+ (BuiltinsInternalsWrapperImplementationGenerator.accessor_name): >+ (BuiltinsInternalsWrapperImplementationGenerator.member_name): >+ (BuiltinsInternalsWrapperImplementationGenerator.member_type): >+ (BuiltinsInternalsWrapperImplementationGenerator.generate_constructor): >+ (BuiltinsInternalsWrapperImplementationGenerator.property_macro): >+ (BuiltinsInternalsWrapperImplementationGenerator.property_macro.DECLARE_GLOBAL_STATIC): >+ (BuiltinsInternalsWrapperImplementationGenerator.generate_visit_method): >+ (BuiltinsInternalsWrapperImplementationGenerator._generate_initialize_static_globals): >+ (BuiltinsInternalsWrapperImplementationGenerator.generate_initialize_method): >+ * Scripts/wkbuiltins/builtins_generate_separate_header.py: Renamed from Source/JavaScriptCore/Scripts/builtins/builtins_generate_separate_header.py. >+ (BuiltinsSeparateHeaderGenerator): >+ (BuiltinsSeparateHeaderGenerator.__init__): >+ (BuiltinsSeparateHeaderGenerator.output_filename): >+ (BuiltinsSeparateHeaderGenerator.macro_prefix): >+ (BuiltinsSeparateHeaderGenerator.generate_output): >+ (BuiltinsSeparateHeaderGenerator.generate_forward_declarations): >+ (FunctionExecutable): >+ (generate_secondary_header_includes): >+ (generate_section_for_object): >+ (generate_externs_for_object): >+ (generate_macros_for_object): >+ (generate_defines_for_object): >+ (generate_section_for_code_table_macro): >+ (generate_section_for_code_name_macro): >+ * Scripts/wkbuiltins/builtins_generate_separate_implementation.py: Renamed from Source/JavaScriptCore/Scripts/builtins/builtins_generate_separate_implementation.py. >+ (BuiltinsSeparateImplementationGenerator): >+ (BuiltinsSeparateImplementationGenerator.__init__): >+ (BuiltinsSeparateImplementationGenerator.output_filename): >+ (BuiltinsSeparateImplementationGenerator.macro_prefix): >+ (BuiltinsSeparateImplementationGenerator.generate_output): >+ (BuiltinsSeparateImplementationGenerator.generate_secondary_header_includes): >+ * Scripts/wkbuiltins/builtins_generate_wrapper_header.py: Renamed from Source/JavaScriptCore/Scripts/builtins/builtins_generate_wrapper_header.py. >+ (BuiltinsWrapperHeaderGenerator): >+ (BuiltinsWrapperHeaderGenerator.__init__): >+ (BuiltinsWrapperHeaderGenerator.output_filename): >+ (BuiltinsWrapperHeaderGenerator.generate_output): >+ (BuiltinsWrapperHeaderGenerator.generate_secondary_header_includes): >+ (BuiltinsWrapperHeaderGenerator.generate_section_for_object): >+ (BuiltinsWrapperHeaderGenerator.generate_section_for_object.JSBuiltinFunctions): >+ (BuiltinsWrapperHeaderGenerator.accessor_name): >+ (BuiltinsWrapperHeaderGenerator.member_name): >+ (BuiltinsWrapperHeaderGenerator.member_type): >+ (BuiltinsWrapperHeaderGenerator.generate_constructor): >+ (BuiltinsWrapperHeaderGenerator.generate_accessors): >+ (BuiltinsWrapperHeaderGenerator.generate_members): >+ * Scripts/wkbuiltins/builtins_generate_wrapper_implementation.py: Renamed from Source/JavaScriptCore/Scripts/builtins/builtins_generate_wrapper_implementation.py. >+ (BuiltinsWrapperImplementationGenerator): >+ (BuiltinsWrapperImplementationGenerator.__init__): >+ (BuiltinsWrapperImplementationGenerator.output_filename): >+ (BuiltinsWrapperImplementationGenerator.generate_output): >+ (BuiltinsWrapperImplementationGenerator.generate_section_for_object): >+ * Scripts/wkbuiltins/builtins_generator.py: Renamed from Source/JavaScriptCore/Scripts/builtins/builtins_generator.py. >+ (WK_lcfirst): >+ (WK_ucfirst): >+ (BuiltinsGenerator): >+ (BuiltinsGenerator.__init__): >+ (BuiltinsGenerator.model): >+ (BuiltinsGenerator.generate_output): >+ (BuiltinsGenerator.output_filename): >+ (BuiltinsGenerator.generate_license): >+ (BuiltinsGenerator.generate_includes_from_entries): >+ (BuiltinsGenerator.generate_primary_header_includes): >+ (BuiltinsGenerator.generate_embedded_code_string_section_for_function): >+ (BuiltinsGenerator.wrap_with_guard): >+ (BuiltinsGenerator.mangledNameForObject): >+ (BuiltinsGenerator.mangledNameForObject.toCamel): >+ (BuiltinsGenerator.mangledNameForFunction): >+ (BuiltinsGenerator.mangledNameForFunction.toCamel): >+ * Scripts/wkbuiltins/builtins_model.py: Renamed from Source/JavaScriptCore/Scripts/builtins/builtins_model.py. >+ (ParseException): >+ (Framework): >+ (Framework.__init__): >+ (Framework.setting): >+ (Framework.fromString): >+ (Frameworks): >+ (BuiltinObject): >+ (BuiltinObject.__init__): >+ (BuiltinFunction): >+ (BuiltinFunction.__init__): >+ (BuiltinFunction.fromString): >+ (BuiltinFunction.__str__): >+ (BuiltinFunction.__lt__): >+ (BuiltinsCollection): >+ (BuiltinsCollection.__init__): >+ (BuiltinsCollection.parse_builtins_file): >+ (BuiltinsCollection.copyrights): >+ (BuiltinsCollection.all_functions): >+ (BuiltinsCollection.all_internal_functions): >+ (BuiltinsCollection._parse_copyright_lines): >+ (BuiltinsCollection._parse_annotations): >+ (BuiltinsCollection._parse_functions): >+ * Scripts/wkbuiltins/builtins_templates.py: Renamed from Source/JavaScriptCore/Scripts/builtins/builtins_templates.py. >+ (BuiltinsGeneratorTemplates): >+ * disassembler/udis86/ud_opcode.py: >+ (UdOpcodeTables.pprint.printWalk): >+ * generate-bytecode-files: >+ * inspector/scripts/codegen/__init__.py: >+ * inspector/scripts/codegen/cpp_generator.py: >+ * inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py: >+ (CppAlternateBackendDispatcherHeaderGenerator.generate_output): >+ * inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py: >+ (CppBackendDispatcherHeaderGenerator.domains_to_generate): >+ (CppBackendDispatcherHeaderGenerator.generate_output): >+ (CppBackendDispatcherHeaderGenerator._generate_dispatcher_declarations_for_domain): >+ * inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py: >+ (CppBackendDispatcherImplementationGenerator.domains_to_generate): >+ (CppBackendDispatcherImplementationGenerator.generate_output): >+ * inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py: >+ (CppFrontendDispatcherHeaderGenerator.domains_to_generate): >+ (CppFrontendDispatcherHeaderGenerator.generate_output): >+ * inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py: >+ (CppFrontendDispatcherImplementationGenerator.domains_to_generate): >+ (CppFrontendDispatcherImplementationGenerator.generate_output): >+ * inspector/scripts/codegen/generate_cpp_protocol_types_header.py: >+ (CppProtocolTypesHeaderGenerator.generate_output): >+ (CppProtocolTypesHeaderGenerator._generate_forward_declarations): >+ * inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py: >+ (CppProtocolTypesImplementationGenerator.generate_output): >+ (CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain): >+ (CppProtocolTypesImplementationGenerator._generate_enum_mapping_and_conversion_methods): >+ (CppProtocolTypesImplementationGenerator._generate_open_field_names): >+ (CppProtocolTypesImplementationGenerator._generate_builders_for_domain): >+ (CppProtocolTypesImplementationGenerator._generate_assertion_for_object_declaration): >+ * inspector/scripts/codegen/generate_js_backend_commands.py: >+ (JSBackendCommandsGenerator.should_generate_domain): >+ (JSBackendCommandsGenerator.domains_to_generate): >+ (JSBackendCommandsGenerator.generate_output): >+ (JSBackendCommandsGenerator.generate_domain): >+ * inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py: >+ (ObjCBackendDispatcherHeaderGenerator.domains_to_generate): >+ (ObjCBackendDispatcherHeaderGenerator.generate_output): >+ * inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py: >+ (ObjCBackendDispatcherImplementationGenerator.domains_to_generate): >+ (ObjCBackendDispatcherImplementationGenerator.generate_output): >+ (ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command): >+ * inspector/scripts/codegen/generate_objc_configuration_header.py: >+ * inspector/scripts/codegen/generate_objc_configuration_implementation.py: >+ * inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py: >+ (ObjCFrontendDispatcherImplementationGenerator.domains_to_generate): >+ (ObjCFrontendDispatcherImplementationGenerator.generate_output): >+ (ObjCFrontendDispatcherImplementationGenerator._generate_event): >+ * inspector/scripts/codegen/generate_objc_header.py: >+ (ObjCHeaderGenerator.generate_output): >+ (ObjCHeaderGenerator._generate_type_interface): >+ * inspector/scripts/codegen/generate_objc_internal_header.py: >+ (ObjCInternalHeaderGenerator.generate_output): >+ * inspector/scripts/codegen/generate_objc_protocol_type_conversions_header.py: >+ (ObjCProtocolTypeConversionsHeaderGenerator.domains_to_generate): >+ (ObjCProtocolTypeConversionsHeaderGenerator.generate_output): >+ * inspector/scripts/codegen/generate_objc_protocol_type_conversions_implementation.py: >+ (ObjCProtocolTypeConversionsImplementationGenerator.domains_to_generate): >+ * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: >+ (ObjCProtocolTypesImplementationGenerator.domains_to_generate): >+ (ObjCProtocolTypesImplementationGenerator.generate_output): >+ (ObjCProtocolTypesImplementationGenerator.generate_type_implementation): >+ (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_required_members): >+ * inspector/scripts/codegen/generator.py: >+ (Generator.non_supplemental_domains): >+ (Generator.open_fields): >+ (Generator.calculate_types_requiring_shape_assertions): >+ (Generator._traverse_and_assign_enum_values): >+ (Generator.stylized_name_for_enum_value): >+ * inspector/scripts/codegen/models.py: >+ (find_duplicates): >+ * inspector/scripts/codegen/objc_generator.py: >+ * wasm/generateWasm.py: >+ (opcodeIterator): >+ * yarr/generateYarrCanonicalizeUnicode: >+ > 2018-08-24 Yusuke Suzuki <yusukesuzuki@slowstart.org> > > [JSC] Array.prototype.reverse modifies JSImmutableButterfly >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index c781a535526bea95d38b185f459b3f1d0a812b59..b5bdeb3a72ab81076bdac1c3cf053e1ccadd8b00 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,15 @@ >+2018-08-27 Mike Gorse <mgorse@suse.com> >+ >+ Build tools should work when the /usr/bin/python is python3 >+ https://bugs.webkit.org/show_bug.cgi?id=156674 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ No new tests (OOPS!). >+ >+ * CMakeLists.txt: builtins -> wkbuiltins >+ * platform/network/create-http-header-name-table: >+ > 2018-08-27 Alex Christensen <achristensen@webkit.org> > > Fix IOSMAC build >diff --git a/Source/WebInspectorUI/ChangeLog b/Source/WebInspectorUI/ChangeLog >index 434d03e3d059b79b866563566c9d695c244a7a2d..d9453493e7a2116ee8d1630b2d772c341a2320b9 100644 >--- a/Source/WebInspectorUI/ChangeLog >+++ b/Source/WebInspectorUI/ChangeLog >@@ -1,3 +1,13 @@ >+2018-08-27 Mike Gorse <mgorse@suse.com> >+ >+ Build tools should work when the /usr/bin/python is python3 >+ https://bugs.webkit.org/show_bug.cgi?id=156674 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Scripts/copy-user-interface-resources.pl: Get path of python >+ from $PYTHON if set. >+ > 2018-08-23 Devin Rousso <drousso@apple.com> > > Web Inspector: Color picker: can't enter decimal numbers for opacity >diff --git a/Source/JavaScriptCore/CMakeLists.txt b/Source/JavaScriptCore/CMakeLists.txt >index fb1d0cc6b246a7a6a5d7ec0921927327e195994b..4382b285e9ea7705e543e17d1569d592bf36960c 100644 >--- a/Source/JavaScriptCore/CMakeLists.txt >+++ b/Source/JavaScriptCore/CMakeLists.txt >@@ -136,7 +136,8 @@ set(JavaScriptCore_SCRIPTS_SOURCES_DIR "${JAVASCRIPTCORE_DIR}/Scripts") > set(JavaScriptCore_SCRIPTS_SOURCES_PATHS > ${JavaScriptCore_SCRIPTS_SOURCES_DIR}/*.pl > ${JavaScriptCore_SCRIPTS_SOURCES_DIR}/*.py >- ${JavaScriptCore_SCRIPTS_SOURCES_DIR}/builtins/builtins*.py >+ ${JavaScriptCore_SCRIPTS_SOURCES_DIR}/wkbuiltins/builtins*.py >+ ${JavaScriptCore_SCRIPTS_SOURCES_DIR}/wkbuiltins/wkbuiltins.py > ) > > # Force JavaScriptCore to run scripts from the same staging path as WebCore. >@@ -1086,7 +1087,7 @@ add_custom_command( > # JSCBuiltins > > set(BUILTINS_GENERATOR_SCRIPTS >- ${JavaScriptCore_SCRIPTS_DIR}/builtins.py >+ ${JavaScriptCore_SCRIPTS_DIR}/wkbuiltins.py > ${JavaScriptCore_SCRIPTS_DIR}/builtins_generator.py > ${JavaScriptCore_SCRIPTS_DIR}/builtins_model.py > ${JavaScriptCore_SCRIPTS_DIR}/builtins_templates.py >diff --git a/Source/JavaScriptCore/Scripts/builtins/__init__.py b/Source/JavaScriptCore/Scripts/builtins/__init__.py >deleted file mode 100644 >index fdfcba981d8f8da0781358cfe64fa1c78074a160..0000000000000000000000000000000000000000 >--- a/Source/JavaScriptCore/Scripts/builtins/__init__.py >+++ /dev/null >@@ -1,3 +0,0 @@ >-# Required for Python to search this directory for module files >- >-from builtins import * >diff --git a/Source/JavaScriptCore/Scripts/builtins/builtins.py b/Source/JavaScriptCore/Scripts/builtins/builtins.py >deleted file mode 100644 >index a9aff2b1cff4f25350b7658dda49c0a5123e9c14..0000000000000000000000000000000000000000 >--- a/Source/JavaScriptCore/Scripts/builtins/builtins.py >+++ /dev/null >@@ -1,15 +0,0 @@ >-# This file is used to simulate the builtins/ directory when generate-js-builtins.py >-# is run from JavaScriptCore framework's private headers directory, which is flattened. >- >-from builtins_model import * >-from builtins_templates import * >- >-from builtins_generator import * >-from builtins_generate_combined_header import * >-from builtins_generate_combined_implementation import * >-from builtins_generate_separate_header import * >-from builtins_generate_separate_implementation import * >-from builtins_generate_wrapper_header import * >-from builtins_generate_wrapper_implementation import * >-from builtins_generate_internals_wrapper_header import * >-from builtins_generate_internals_wrapper_implementation import * >diff --git a/Source/JavaScriptCore/Scripts/builtins/builtins_generate_combined_header.py b/Source/JavaScriptCore/Scripts/builtins/builtins_generate_combined_header.py >deleted file mode 100755 >index cde357cd439ceaf446428e68188478073c03c49d..0000000000000000000000000000000000000000 >--- a/Source/JavaScriptCore/Scripts/builtins/builtins_generate_combined_header.py >+++ /dev/null >@@ -1,171 +0,0 @@ >-#!/usr/bin/env python >-# >-# Copyright (c) 2014-2016 Apple Inc. All rights reserved. >-# Copyright (c) 2014 University of Washington. All rights reserved. >-# >-# Redistribution and use in source and binary forms, with or without >-# modification, are permitted provided that the following conditions >-# are met: >-# 1. Redistributions of source code must retain the above copyright >-# notice, this list of conditions and the following disclaimer. >-# 2. 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. >-# >-# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 logging >-import re >-import string >-from string import Template >- >-from builtins_generator import BuiltinsGenerator >-from builtins_templates import BuiltinsGeneratorTemplates as Templates >- >-log = logging.getLogger('global') >- >- >-class BuiltinsCombinedHeaderGenerator(BuiltinsGenerator): >- def __init__(self, model): >- BuiltinsGenerator.__init__(self, model) >- >- def output_filename(self): >- return "%sBuiltins.h" % self.model().framework.setting('namespace') >- >- def generate_output(self): >- args = { >- 'namespace': self.model().framework.setting('namespace'), >- 'macroPrefix': self.model().framework.setting('macro_prefix'), >- } >- >- sections = [] >- sections.append(self.generate_license()) >- sections.append(Template(Templates.DoNotEditWarning).substitute(args)) >- sections.append(Template(Templates.HeaderIncludeGuard).substitute(args)) >- sections.append(self.generate_forward_declarations()) >- sections.append(Template(Templates.NamespaceTop).substitute(args)) >- for object in self.model().objects: >- sections.append(self.generate_section_for_object(object)) >- sections.append(self.generate_section_for_code_table_macro()) >- sections.append(self.generate_section_for_code_name_macro()) >- sections.append(self.generate_section_for_global_private_code_name_macro()) >- sections.append(Template(Templates.CombinedHeaderStaticMacros).substitute(args)) >- sections.append(Template(Templates.NamespaceBottom).substitute(args)) >- >- return "\n\n".join(sections) >- >- def generate_forward_declarations(self): >- return """namespace JSC { >-class FunctionExecutable; >-class VM; >- >-enum class ConstructAbility : unsigned; >-}""" >- >- def generate_section_for_object(self, object): >- lines = [] >- lines.append('/* %s */' % object.object_name) >- lines.extend(self.generate_externs_for_object(object)) >- lines.append("") >- lines.extend(self.generate_macros_for_object(object)) >- return '\n'.join(lines) >- >- def generate_externs_for_object(self, object): >- lines = [] >- >- for function in object.functions: >- function_args = { >- 'codeName': BuiltinsGenerator.mangledNameForFunction(function) + 'Code', >- } >- >- lines.append("""extern const char* s_%(codeName)s; >-extern const int s_%(codeName)sLength; >-extern const JSC::ConstructAbility s_%(codeName)sConstructAbility;""" % function_args) >- >- return lines >- >- def generate_macros_for_object(self, object): >- args = { >- 'macroPrefix': self.model().framework.setting('macro_prefix'), >- 'objectMacro': object.object_name.replace('.', '').upper(), >- } >- >- lines = [] >- lines.append("#define %(macroPrefix)s_FOREACH_%(objectMacro)s_BUILTIN_DATA(macro) \\" % args) >- for function in object.functions: >- function_args = { >- 'funcName': function.function_name, >- 'mangledName': BuiltinsGenerator.mangledNameForFunction(function), >- 'paramCount': len(function.parameters), >- } >- >- lines.append(" macro(%(funcName)s, %(mangledName)s, %(paramCount)d) \\" % function_args) >- return lines >- >- def generate_section_for_code_table_macro(self): >- args = { >- 'macroPrefix': self.model().framework.setting('macro_prefix'), >- } >- >- lines = [] >- lines.append("#define %(macroPrefix)s_FOREACH_BUILTIN_CODE(macro) \\" % args) >- for function in self.model().all_functions(): >- function_args = { >- 'funcName': function.function_name, >- 'overriddenName': function.overridden_name, >- 'codeName': BuiltinsGenerator.mangledNameForFunction(function) + 'Code', >- } >- >- lines.append(" macro(%(codeName)s, %(funcName)s, %(overriddenName)s, s_%(codeName)sLength) \\" % function_args) >- return '\n'.join(lines) >- >- def generate_section_for_code_name_macro(self): >- args = { >- 'macroPrefix': self.model().framework.setting('macro_prefix'), >- } >- >- internal_function_names = [function.function_name for function in self.model().all_internal_functions()] >- if len(internal_function_names) != len(set(internal_function_names)): >- log.error("There are several internal functions with the same name. Private identifiers may clash.") >- >- lines = [] >- lines.append("#define %(macroPrefix)s_FOREACH_BUILTIN_FUNCTION_NAME(macro) \\" % args) >- unique_names = list(set([function.function_name for function in self.model().all_functions()])) >- unique_names.sort() >- for function_name in unique_names: >- function_args = { >- 'funcName': function_name, >- } >- >- lines.append(" macro(%(funcName)s) \\" % function_args) >- return '\n'.join(lines) >- >- def generate_section_for_global_private_code_name_macro(self): >- args = { >- 'macroPrefix': self.model().framework.setting('macro_prefix'), >- } >- >- lines = [] >- lines.append("#define %(macroPrefix)s_FOREACH_BUILTIN_FUNCTION_PRIVATE_GLOBAL_NAME(macro) \\" % args) >- functions = filter(lambda function: function.is_global_private, self.model().all_functions()) >- functions.sort(key=lambda x: x.function_name) >- for function in functions: >- function_args = { >- 'funcName': function.function_name, >- 'codeName': BuiltinsGenerator.mangledNameForFunction(function), >- } >- >- lines.append(" macro(%(funcName)s, %(codeName)s) \\" % function_args) >- >- return '\n'.join(lines) >diff --git a/Source/JavaScriptCore/Scripts/builtins/builtins_generate_combined_implementation.py b/Source/JavaScriptCore/Scripts/builtins/builtins_generate_combined_implementation.py >deleted file mode 100644 >index 7874dcad94b4a6a2fc7c418f04e69d1395c1edb0..0000000000000000000000000000000000000000 >--- a/Source/JavaScriptCore/Scripts/builtins/builtins_generate_combined_implementation.py >+++ /dev/null >@@ -1,100 +0,0 @@ >-#!/usr/bin/env python >-# >-# Copyright (c) 2014, 2015 Apple Inc. All rights reserved. >-# Copyright (c) 2014 University of Washington. All rights reserved. >-# >-# Redistribution and use in source and binary forms, with or without >-# modification, are permitted provided that the following conditions >-# are met: >-# 1. Redistributions of source code must retain the above copyright >-# notice, this list of conditions and the following disclaimer. >-# 2. 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. >-# >-# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 logging >-import re >-import string >-from string import Template >- >-from builtins_generator import BuiltinsGenerator >-from builtins_model import Framework, Frameworks >-from builtins_templates import BuiltinsGeneratorTemplates as Templates >- >-log = logging.getLogger('global') >- >- >-class BuiltinsCombinedImplementationGenerator(BuiltinsGenerator): >- def __init__(self, model): >- BuiltinsGenerator.__init__(self, model) >- >- def output_filename(self): >- return "%sBuiltins.cpp" % self.model().framework.setting('namespace') >- >- def generate_output(self): >- args = { >- 'namespace': self.model().framework.setting('namespace'), >- 'macroPrefix': self.model().framework.setting('macro_prefix'), >- } >- >- sections = [] >- sections.append(self.generate_license()) >- sections.append(Template(Templates.DoNotEditWarning).substitute(args)) >- sections.append(self.generate_primary_header_includes()) >- sections.append(self.generate_secondary_header_includes()) >- sections.append(Template(Templates.NamespaceTop).substitute(args)) >- for function in self.model().all_functions(): >- sections.append(self.generate_embedded_code_string_section_for_function(function)) >- if self.model().framework is Frameworks.JavaScriptCore: >- sections.append(Template(Templates.CombinedJSCImplementationStaticMacros).substitute(args)) >- elif self.model().framework is Frameworks.WebCore: >- sections.append(Template(Templates.CombinedWebCoreImplementationStaticMacros).substitute(args)) >- sections.append(Template(Templates.NamespaceBottom).substitute(args)) >- >- return "\n\n".join(sections) >- >- def generate_secondary_header_includes(self): >- header_includes = [ >- (["JavaScriptCore"], >- ("JavaScriptCore", "builtins/BuiltinExecutables.h"), >- ), >- (["JavaScriptCore", "WebCore"], >- ("JavaScriptCore", "heap/HeapInlines.h"), >- ), >- (["JavaScriptCore", "WebCore"], >- ("JavaScriptCore", "runtime/UnlinkedFunctionExecutable.h"), >- ), >- (["JavaScriptCore", "WebCore"], >- ("JavaScriptCore", "runtime/JSCellInlines.h"), >- ), >- (["WebCore"], >- ("JavaScriptCore", "runtime/StructureInlines.h"), >- ), >- (["WebCore"], >- ("JavaScriptCore", "runtime/JSCJSValueInlines.h"), >- ), >- (["JavaScriptCore", "WebCore"], >- ("JavaScriptCore", "runtime/VM.h"), >- ), >- (["JavaScriptCore", "WebCore"], >- ("JavaScriptCore", "runtime/IdentifierInlines.h"), >- ), >- (["JavaScriptCore", "WebCore"], >- ("JavaScriptCore", "runtime/Intrinsic.h"), >- ), >- ] >- >- return '\n'.join(self.generate_includes_from_entries(header_includes)) >diff --git a/Source/JavaScriptCore/Scripts/builtins/builtins_generate_internals_wrapper_header.py b/Source/JavaScriptCore/Scripts/builtins/builtins_generate_internals_wrapper_header.py >deleted file mode 100755 >index 0b913dcfce03610e4096075aa44a3ee2b42039cb..0000000000000000000000000000000000000000 >--- a/Source/JavaScriptCore/Scripts/builtins/builtins_generate_internals_wrapper_header.py >+++ /dev/null >@@ -1,113 +0,0 @@ >-#!/usr/bin/env python >-# >-# Copyright (c) 2016 Apple 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: >-# 1. Redistributions of source code must retain the above copyright >-# notice, this list of conditions and the following disclaimer. >-# 2. 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. >-# >-# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 logging >-from string import Template >- >-from builtins_generator import BuiltinsGenerator, WK_lcfirst, WK_ucfirst >-from builtins_templates import BuiltinsGeneratorTemplates as Templates >- >-log = logging.getLogger('global') >- >- >-class BuiltinsInternalsWrapperHeaderGenerator(BuiltinsGenerator): >- def __init__(self, model): >- BuiltinsGenerator.__init__(self, model) >- self.internals = filter(lambda object: 'internal' in object.annotations, model.objects) >- >- def output_filename(self): >- return "%sJSBuiltinInternals.h" % self.model().framework.setting('namespace') >- >- def generate_output(self): >- args = { >- 'namespace': self.model().framework.setting('namespace'), >- } >- >- sections = [] >- sections.append(self.generate_license()) >- sections.append(Template(Templates.DoNotEditWarning).substitute(args)) >- sections.append(Template(Templates.HeaderIncludeGuard).substitute(args)) >- sections.append(self.generate_secondary_header_includes()) >- >- sections.append(Template(Templates.NamespaceTop).substitute(args)) >- sections.append(self.generate_section_for_object()) >- sections.append(Template(Templates.NamespaceBottom).substitute(args)) >- >- return "\n\n".join(sections) >- >- def generate_secondary_header_includes(self): >- header_includes = [ >- (["WebCore"], ("JavaScriptCore", "heap/WeakInlines.h")), >- (["WebCore"], ("JavaScriptCore", "runtime/VM.h")) >- ] >- for object in self.internals: >- header_includes.append((["WebCore"], ("WebCore", object.object_name + "Builtins.h"))) >- >- return '\n'.join(self.generate_includes_from_entries(header_includes)) >- >- def generate_section_for_object(self): >- lines = ["class JSDOMGlobalObject;", >- "", >- "class JSBuiltinInternalFunctions {", >- "public:"] >- >- lines.append(" explicit JSBuiltinInternalFunctions(JSC::VM&);") >- lines.append(self.generate_methods()) >- lines.append(self.generate_accessors()) >- lines.append("private:") >- lines.append(self.generate_members()) >- lines.append("};") >- return '\n'.join(lines) >- >- def accessor_name(self, object): >- return WK_lcfirst(object.object_name) >- >- def member_name(self, object): >- return "m_" + self.accessor_name(object) >- >- def member_type(self, object): >- return WK_ucfirst(object.object_name) + "BuiltinFunctions" >- >- def generate_methods(self): >- return """ >- void visit(JSC::SlotVisitor&); >- void initialize(JSDOMGlobalObject&); >-""" >- >- def generate_accessors(self): >- lines = [] >- for object in self.internals: >- accessor = " %s& %s() { return %s; }" % (self.member_type(object), self.accessor_name(object), self.member_name(object)) >- lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), accessor)) >- lines.append("") >- return '\n'.join(lines) >- >- def generate_members(self): >- lines = [" JSC::VM& m_vm;"] >- for object in self.internals: >- member = " %s %s;" % (self.member_type(object), self.member_name(object)) >- lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), member)) >- return '\n'.join(lines) >diff --git a/Source/JavaScriptCore/Scripts/builtins/builtins_generate_internals_wrapper_implementation.py b/Source/JavaScriptCore/Scripts/builtins/builtins_generate_internals_wrapper_implementation.py >deleted file mode 100755 >index 52b4b2025f22f60c702b70263ac2429045df282d..0000000000000000000000000000000000000000 >--- a/Source/JavaScriptCore/Scripts/builtins/builtins_generate_internals_wrapper_implementation.py >+++ /dev/null >@@ -1,156 +0,0 @@ >-#!/usr/bin/env python >-# >-# Copyright (c) 2016 Apple 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: >-# 1. Redistributions of source code must retain the above copyright >-# notice, this list of conditions and the following disclaimer. >-# 2. 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. >-# >-# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 logging >-from string import Template >- >-from builtins_generator import BuiltinsGenerator, WK_lcfirst, WK_ucfirst >-from builtins_templates import BuiltinsGeneratorTemplates as Templates >- >-log = logging.getLogger('global') >- >- >-class BuiltinsInternalsWrapperImplementationGenerator(BuiltinsGenerator): >- def __init__(self, model): >- BuiltinsGenerator.__init__(self, model) >- self.internals = filter(lambda object: 'internal' in object.annotations, model.objects) >- >- def output_filename(self): >- return "%sJSBuiltinInternals.cpp" % self.model().framework.setting('namespace') >- >- def generate_output(self): >- args = { >- 'namespace': self.model().framework.setting('namespace'), >- } >- >- sections = [] >- sections.append(self.generate_license()) >- sections.append(Template(Templates.DoNotEditWarning).substitute(args)) >- sections.append(self.generate_primary_header_includes()) >- sections.append(self.generate_secondary_header_includes()) >- >- sections.append(Template(Templates.NamespaceTop).substitute(args)) >- sections.append(self.generate_section_for_object()) >- sections.append(Template(Templates.NamespaceBottom).substitute(args)) >- >- return "\n\n".join(sections) >- >- def generate_secondary_header_includes(self): >- header_includes = [ >- (["WebCore"], >- ("WebCore", "JSDOMGlobalObject.h"), >- ), >- (["WebCore"], >- ("WebCore", "WebCoreJSClientData.h"), >- ), >- (["WebCore"], >- ("JavaScriptCore", "heap/HeapInlines.h"), >- ), >- (["WebCore"], >- ("JavaScriptCore", "heap/SlotVisitorInlines.h"), >- ), >- (["WebCore"], >- ("JavaScriptCore", "runtime/JSCJSValueInlines.h"), >- ), >- (["WebCore"], >- ("JavaScriptCore", "runtime/StructureInlines.h"), >- ), >- ] >- return '\n'.join(self.generate_includes_from_entries(header_includes)) >- >- def generate_section_for_object(self): >- lines = [] >- >- lines.append(self.generate_constructor()) >- lines.append(self.generate_visit_method()) >- lines.append(self.generate_initialize_method()) >- return '\n'.join(lines) >- >- def accessor_name(self, object): >- return WK_lcfirst(object.object_name) >- >- def member_name(self, object): >- return "m_" + self.accessor_name(object) >- >- def member_type(self, object): >- return WK_ucfirst(object.object_name) + "BuiltinFunctions" >- >- def generate_constructor(self): >- guards = set([object.annotations.get('conditional') for object in self.internals if 'conditional' in object.annotations]) >- lines = ["JSBuiltinInternalFunctions::JSBuiltinInternalFunctions(JSC::VM& vm)", >- " : m_vm(vm)"] >- for object in self.internals: >- initializer = " , %s(m_vm)" % self.member_name(object) >- lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), initializer)) >- lines.append("{") >- lines.append(" UNUSED_PARAM(vm);") >- lines.append("}\n") >- return '\n'.join(lines) >- >- def property_macro(self, object): >- lines = [] >- lines.append("#define DECLARE_GLOBAL_STATIC(name) \\") >- lines.append(" JSDOMGlobalObject::GlobalPropertyInfo( \\") >- lines.append(" clientData.builtinFunctions().%sBuiltins().name##PrivateName(), %s().m_##name##Function.get() , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)," % (self.accessor_name(object), self.accessor_name(object))) >- lines.append(" WEBCORE_FOREACH_%s_BUILTIN_FUNCTION_NAME(DECLARE_GLOBAL_STATIC)" % object.object_name.upper()) >- lines.append("#undef DECLARE_GLOBAL_STATIC") >- return '\n'.join(lines) >- >- def generate_visit_method(self): >- lines = ["void JSBuiltinInternalFunctions::visit(JSC::SlotVisitor& visitor)", >- "{"] >- for object in self.internals: >- visit = " %s.visit(visitor);" % self.member_name(object) >- lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), visit)) >- lines.append(" UNUSED_PARAM(visitor);") >- lines.append("}\n") >- return '\n'.join(lines) >- >- def _generate_initialize_static_globals(self): >- lines = [" JSVMClientData& clientData = *static_cast<JSVMClientData*>(m_vm.clientData);", >- " JSDOMGlobalObject::GlobalPropertyInfo staticGlobals[] = {"] >- for object in self.internals: >- lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), self.property_macro(object))) >- lines.append(" };") >- lines.append(" globalObject.addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals));") >- lines.append(" UNUSED_PARAM(clientData);") >- return '\n'.join(lines) >- >- def generate_initialize_method(self): >- lines = ["void JSBuiltinInternalFunctions::initialize(JSDOMGlobalObject& globalObject)", >- "{", >- " UNUSED_PARAM(globalObject);"] >- >- for object in self.internals: >- init = " %s.init(globalObject);" % self.member_name(object) >- lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), init)) >- lines.append("") >- >- guards = set([object.annotations.get('conditional') for object in self.internals if 'conditional' in object.annotations]) >- lines.append(BuiltinsGenerator.wrap_with_guard(" || ".join(guards), self._generate_initialize_static_globals())) >- >- lines.append("}") >- return '\n'.join(lines) >diff --git a/Source/JavaScriptCore/Scripts/builtins/builtins_generate_separate_header.py b/Source/JavaScriptCore/Scripts/builtins/builtins_generate_separate_header.py >deleted file mode 100755 >index 58c8f2ac8a6415a291cff888cf1f680c1d66047d..0000000000000000000000000000000000000000 >--- a/Source/JavaScriptCore/Scripts/builtins/builtins_generate_separate_header.py >+++ /dev/null >@@ -1,198 +0,0 @@ >-#!/usr/bin/env python >-# >-# Copyright (c) 2014, 2015 Apple Inc. All rights reserved. >-# Copyright (c) 2014 University of Washington. All rights reserved. >-# >-# Redistribution and use in source and binary forms, with or without >-# modification, are permitted provided that the following conditions >-# are met: >-# 1. Redistributions of source code must retain the above copyright >-# notice, this list of conditions and the following disclaimer. >-# 2. 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. >-# >-# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 logging >-import re >-import string >-from string import Template >- >-from builtins_generator import BuiltinsGenerator >-from builtins_model import Frameworks >-from builtins_templates import BuiltinsGeneratorTemplates as Templates >- >-log = logging.getLogger('global') >- >- >-class BuiltinsSeparateHeaderGenerator(BuiltinsGenerator): >- def __init__(self, model, object): >- BuiltinsGenerator.__init__(self, model) >- self.object = object >- >- def output_filename(self): >- return "%sBuiltins.h" % BuiltinsGenerator.mangledNameForObject(self.object) >- >- def macro_prefix(self): >- return self.model().framework.setting('macro_prefix') >- >- def generate_output(self): >- args = { >- 'namespace': self.model().framework.setting('namespace'), >- 'macroPrefix': self.macro_prefix(), >- 'objectName': self.object.object_name, >- 'objectMacro': self.object.object_name.upper(), >- } >- >- conditional_guard = self.object.annotations.get('conditional') >- >- sections = [] >- sections.append(self.generate_license()) >- sections.append(Template(Templates.DoNotEditWarning).substitute(args)) >- sections.append(Template(Templates.HeaderIncludeGuard).substitute(args)) >- if conditional_guard is not None: >- sections.append("#if %s" % conditional_guard) >- sections.append(self.generate_secondary_header_includes()) >- sections.append(self.generate_forward_declarations()) >- sections.append(Template(Templates.NamespaceTop).substitute(args)) >- sections.append(self.generate_section_for_object(self.object)) >- sections.append(self.generate_section_for_code_table_macro()) >- sections.append(self.generate_section_for_code_name_macro()) >- sections.append(Template(Templates.SeparateHeaderStaticMacros).substitute(args)) >- if self.model().framework is Frameworks.WebCore: >- sections.append(Template(Templates.SeparateHeaderWrapperBoilerplate).substitute(args)) >- if self.object.annotations.get('internal'): >- sections.append(Template(Templates.SeparateHeaderInternalFunctionsBoilerplate).substitute(args)) >- sections.append(Template(Templates.NamespaceBottom).substitute(args)) >- if conditional_guard is not None: >- sections.append("#endif // %s" % conditional_guard) >- >- return "\n\n".join(sections) >- >- def generate_forward_declarations(self): >- return """namespace JSC { >-class FunctionExecutable; >-}""" >- >- def generate_secondary_header_includes(self): >- header_includes = [ >- (["WebCore"], >- ("JavaScriptCore", "bytecode/UnlinkedFunctionExecutable.h"), >- ), >- >- (["WebCore"], >- ("JavaScriptCore", "builtins/BuiltinUtils.h"), >- ), >- >- (["WebCore"], >- ("JavaScriptCore", "runtime/Identifier.h"), >- ), >- >- (["WebCore"], >- ("JavaScriptCore", "runtime/JSFunction.h"), >- ), >- ] >- >- return '\n'.join(self.generate_includes_from_entries(header_includes)) >- >- def generate_section_for_object(self, object): >- lines = [] >- lines.append('/* %s */' % object.object_name) >- lines.extend(self.generate_externs_for_object(object)) >- lines.append("") >- lines.extend(self.generate_macros_for_object(object)) >- lines.append("") >- lines.extend(self.generate_defines_for_object(object)) >- return '\n'.join(lines) >- >- def generate_externs_for_object(self, object): >- lines = [] >- >- for function in object.functions: >- function_args = { >- 'codeName': BuiltinsGenerator.mangledNameForFunction(function) + 'Code', >- } >- >- lines.append("""extern const char* s_%(codeName)s; >-extern const int s_%(codeName)sLength; >-extern const JSC::ConstructAbility s_%(codeName)sConstructAbility;""" % function_args) >- >- return lines >- >- def generate_macros_for_object(self, object): >- args = { >- 'macroPrefix': self.macro_prefix(), >- 'objectMacro': object.object_name.replace('.', '_').upper(), >- } >- >- lines = [] >- lines.append("#define %(macroPrefix)s_FOREACH_%(objectMacro)s_BUILTIN_DATA(macro) \\" % args) >- for function in object.functions: >- function_args = { >- 'funcName': function.function_name, >- 'mangledName': BuiltinsGenerator.mangledNameForFunction(function), >- 'paramCount': len(function.parameters), >- } >- >- lines.append(" macro(%(funcName)s, %(mangledName)s, %(paramCount)d) \\" % function_args) >- return lines >- >- def generate_defines_for_object(self, object): >- lines = [] >- for function in object.functions: >- args = { >- 'macroPrefix': self.macro_prefix(), >- 'objectMacro': object.object_name.replace('.', '_').upper(), >- 'functionMacro': function.function_name.upper(), >- } >- lines.append("#define %(macroPrefix)s_BUILTIN_%(objectMacro)s_%(functionMacro)s 1" % args) >- >- return lines >- >- def generate_section_for_code_table_macro(self): >- args = { >- 'macroPrefix': self.model().framework.setting('macro_prefix'), >- 'objectMacro': self.object.object_name.upper(), >- } >- >- lines = [] >- lines.append("#define %(macroPrefix)s_FOREACH_%(objectMacro)s_BUILTIN_CODE(macro) \\" % args) >- for function in self.object.functions: >- function_args = { >- 'funcName': function.function_name, >- 'overriddenName': function.overridden_name, >- 'codeName': BuiltinsGenerator.mangledNameForFunction(function) + 'Code', >- } >- >- lines.append(" macro(%(codeName)s, %(funcName)s, %(overriddenName)s, s_%(codeName)sLength) \\" % function_args) >- return '\n'.join(lines) >- >- def generate_section_for_code_name_macro(self): >- args = { >- 'macroPrefix': self.macro_prefix(), >- 'objectMacro': self.object.object_name.upper(), >- } >- >- lines = [] >- lines.append("#define %(macroPrefix)s_FOREACH_%(objectMacro)s_BUILTIN_FUNCTION_NAME(macro) \\" % args) >- unique_names = list(set([function.function_name for function in self.object.functions])) >- unique_names.sort() >- for function_name in unique_names: >- function_args = { >- 'funcName': function_name, >- } >- >- lines.append(" macro(%(funcName)s) \\" % function_args) >- return '\n'.join(lines) >diff --git a/Source/JavaScriptCore/Scripts/builtins/builtins_generate_separate_implementation.py b/Source/JavaScriptCore/Scripts/builtins/builtins_generate_separate_implementation.py >deleted file mode 100644 >index ced9a53867d42bc88562d208b4724cf6f6684900..0000000000000000000000000000000000000000 >--- a/Source/JavaScriptCore/Scripts/builtins/builtins_generate_separate_implementation.py >+++ /dev/null >@@ -1,112 +0,0 @@ >-#!/usr/bin/env python >-# >-# Copyright (c) 2014, 2015 Apple Inc. All rights reserved. >-# Copyright (c) 2014 University of Washington. All rights reserved. >-# >-# Redistribution and use in source and binary forms, with or without >-# modification, are permitted provided that the following conditions >-# are met: >-# 1. Redistributions of source code must retain the above copyright >-# notice, this list of conditions and the following disclaimer. >-# 2. 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. >-# >-# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 logging >-import re >-import string >-from string import Template >- >-from builtins_generator import BuiltinsGenerator, WK_lcfirst >-from builtins_model import Framework, Frameworks >-from builtins_templates import BuiltinsGeneratorTemplates as Templates >- >-log = logging.getLogger('global') >- >- >-class BuiltinsSeparateImplementationGenerator(BuiltinsGenerator): >- def __init__(self, model, object): >- BuiltinsGenerator.__init__(self, model) >- self.object = object >- >- def output_filename(self): >- return "%sBuiltins.cpp" % BuiltinsGenerator.mangledNameForObject(self.object) >- >- def macro_prefix(self): >- return self.model().framework.setting('macro_prefix') >- >- def generate_output(self): >- args = { >- 'namespace': self.model().framework.setting('namespace'), >- 'macroPrefix': self.macro_prefix(), >- 'objectMacro': self.object.object_name.upper(), >- 'objectNameLC': WK_lcfirst(self.object.object_name), >- } >- >- conditional_guard = self.object.annotations.get('conditional') >- >- sections = [] >- sections.append(self.generate_license()) >- sections.append(Template(Templates.DoNotEditWarning).substitute(args)) >- sections.append(self.generate_primary_header_includes()) >- if conditional_guard is not None: >- sections.append("#if %s" % conditional_guard) >- sections.append(self.generate_secondary_header_includes()) >- sections.append(Template(Templates.NamespaceTop).substitute(args)) >- for function in self.object.functions: >- sections.append(self.generate_embedded_code_string_section_for_function(function)) >- if self.model().framework is Frameworks.JavaScriptCore: >- sections.append(Template(Templates.SeparateJSCImplementationStaticMacros).substitute(args)) >- elif self.model().framework is Frameworks.WebCore: >- sections.append(Template(Templates.SeparateWebCoreImplementationStaticMacros).substitute(args)) >- sections.append(Template(Templates.NamespaceBottom).substitute(args)) >- if conditional_guard is not None: >- sections.append("#endif // %s\n" % conditional_guard) >- >- return "\n\n".join(sections) >- >- def generate_secondary_header_includes(self): >- header_includes = [ >- (["JavaScriptCore"], >- ("JavaScriptCore", "builtins/BuiltinExecutables.h"), >- ), >- (["JavaScriptCore", "WebCore"], >- ("JavaScriptCore", "heap/HeapInlines.h"), >- ), >- (["JavaScriptCore", "WebCore"], >- ("JavaScriptCore", "runtime/JSCellInlines.h"), >- ), >- (["WebCore"], >- ("JavaScriptCore", "runtime/StructureInlines.h"), >- ), >- (["WebCore"], >- ("JavaScriptCore", "runtime/JSCJSValueInlines.h"), >- ), >- (["JavaScriptCore", "WebCore"], >- ("JavaScriptCore", "runtime/VM.h"), >- ), >- (["WebCore"], >- ("WebCore", "bindings/js/WebCoreJSClientData.h"), >- ), >- (["JavaScriptCore", "WebCore"], >- ("JavaScriptCore", "runtime/IdentifierInlines.h"), >- ), >- (["JavaScriptCore", "WebCore"], >- ("JavaScriptCore", "runtime/Intrinsic.h"), >- ), >- ] >- >- return '\n'.join(self.generate_includes_from_entries(header_includes)) >diff --git a/Source/JavaScriptCore/Scripts/builtins/builtins_generate_wrapper_header.py b/Source/JavaScriptCore/Scripts/builtins/builtins_generate_wrapper_header.py >deleted file mode 100755 >index 04abe567803708019699b2ac4c880522fdd85469..0000000000000000000000000000000000000000 >--- a/Source/JavaScriptCore/Scripts/builtins/builtins_generate_wrapper_header.py >+++ /dev/null >@@ -1,119 +0,0 @@ >-#!/usr/bin/env python >-# >-# Copyright (c) 2016 Apple 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: >-# 1. Redistributions of source code must retain the above copyright >-# notice, this list of conditions and the following disclaimer. >-# 2. 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. >-# >-# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 logging >-from string import Template >- >-from builtins_generator import BuiltinsGenerator, WK_lcfirst, WK_ucfirst >-from builtins_templates import BuiltinsGeneratorTemplates as Templates >- >-log = logging.getLogger('global') >- >- >-class BuiltinsWrapperHeaderGenerator(BuiltinsGenerator): >- def __init__(self, model): >- BuiltinsGenerator.__init__(self, model) >- >- def output_filename(self): >- return "%sJSBuiltins.h" % self.model().framework.setting('namespace') >- >- def generate_output(self): >- args = { >- 'namespace': self.model().framework.setting('namespace'), >- } >- >- sections = [] >- sections.append(self.generate_license()) >- sections.append(Template(Templates.DoNotEditWarning).substitute(args)) >- sections.append(Template(Templates.HeaderIncludeGuard).substitute(args)) >- sections.append(self.generate_secondary_header_includes()) >- >- sections.append(Template(Templates.NamespaceTop).substitute(args)) >- sections.append(self.generate_section_for_object()) >- sections.append(Template(Templates.NamespaceBottom).substitute(args)) >- >- return "\n\n".join(sections) >- >- def generate_secondary_header_includes(self): >- header_includes = [ >- (["WebCore"], >- ("JavaScriptCore", "runtime/VM.h"), >- ), >- ] >- for object in self.model().objects: >- header_includes.append((["WebCore"], ("WebCore", object.object_name + "Builtins.h"))) >- >- return '\n'.join(self.generate_includes_from_entries(header_includes)) >- >- def generate_section_for_object(self): >- lines = ["class JSBuiltinFunctions {", >- "public:"] >- >- lines.append(self.generate_constructor()) >- lines.append(self.generate_accessors()) >- lines.append("private:") >- lines.append(self.generate_members()) >- lines.append("};") >- return '\n'.join(lines) >- >- def accessor_name(self, object): >- return WK_lcfirst(object.object_name) + "Builtins" >- >- def member_name(self, object): >- return "m_" + self.accessor_name(object) >- >- def member_type(self, object): >- return WK_ucfirst(object.object_name) + "BuiltinsWrapper" >- >- def generate_constructor(self): >- lines = [" explicit JSBuiltinFunctions(JSC::VM& vm)", >- " : m_vm(vm)"] >- for object in self.model().objects: >- member_init = " , %s(&m_vm)" % self.member_name(object) >- lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), member_init)) >- lines.append(" {") >- for object in self.model().objects: >- if not 'internal' in object.annotations: >- continue >- internal_export_names = " %s.exportNames();" % self.member_name(object) >- lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), internal_export_names)) >- lines.append(" }\n") >- return '\n'.join(lines) >- >- def generate_accessors(self): >- lines = [] >- for object in self.model().objects: >- accessor = " %s& %s() { return %s; }" % (self.member_type(object), self.accessor_name(object), self.member_name(object)) >- lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), accessor)) >- lines.append("") >- return '\n'.join(lines) >- >- def generate_members(self): >- lines = [" JSC::VM& m_vm;"] >- for object in self.model().objects: >- member = " %s %s;" % (self.member_type(object), self.member_name(object)) >- lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), member)) >- return '\n'.join(lines) >diff --git a/Source/JavaScriptCore/Scripts/builtins/builtins_generate_wrapper_implementation.py b/Source/JavaScriptCore/Scripts/builtins/builtins_generate_wrapper_implementation.py >deleted file mode 100755 >index 0055917fdc82d3c6c675916b04ec0f6147c38ee8..0000000000000000000000000000000000000000 >--- a/Source/JavaScriptCore/Scripts/builtins/builtins_generate_wrapper_implementation.py >+++ /dev/null >@@ -1,61 +0,0 @@ >-#!/usr/bin/env python >-# >-# Copyright (c) 2016 Apple 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: >-# 1. Redistributions of source code must retain the above copyright >-# notice, this list of conditions and the following disclaimer. >-# 2. 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. >-# >-# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 logging >-from string import Template >- >-from builtins_generator import BuiltinsGenerator >-from builtins_templates import BuiltinsGeneratorTemplates as Templates >- >-log = logging.getLogger('global') >- >- >-class BuiltinsWrapperImplementationGenerator(BuiltinsGenerator): >- def __init__(self, model): >- BuiltinsGenerator.__init__(self, model) >- >- def output_filename(self): >- return "%sJSBuiltins.cpp" % self.model().framework.setting('namespace') >- >- def generate_output(self): >- args = { >- 'namespace': self.model().framework.setting('namespace'), >- } >- >- sections = [] >- sections.append(self.generate_license()) >- sections.append(Template(Templates.DoNotEditWarning).substitute(args)) >- >- sections.append(self.generate_section_for_object()) >- >- return "\n\n".join(sections) >- >- def generate_section_for_object(self): >- header_includes = [] >- for object in self.model().objects: >- header_includes.append((["WebCore"], ("WebCore", object.object_name + "Builtins.cpp"))) >- >- return '\n'.join(self.generate_includes_from_entries(header_includes)) >diff --git a/Source/JavaScriptCore/Scripts/builtins/builtins_generator.py b/Source/JavaScriptCore/Scripts/builtins/builtins_generator.py >deleted file mode 100644 >index 1f2e80ea361a9e2169710d3bd57e42dc0bee4bfb..0000000000000000000000000000000000000000 >--- a/Source/JavaScriptCore/Scripts/builtins/builtins_generator.py >+++ /dev/null >@@ -1,181 +0,0 @@ >-#!/usr/bin/env python >-# >-# Copyright (c) 2014, 2015 Apple Inc. All rights reserved. >-# Copyright (c) 2014 University of Washington. All rights reserved. >-# >-# Redistribution and use in source and binary forms, with or without >-# modification, are permitted provided that the following conditions >-# are met: >-# 1. Redistributions of source code must retain the above copyright >-# notice, this list of conditions and the following disclaimer. >-# 2. 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. >-# >-# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 logging >-import os.path >-import re >-from string import Template >-import json >- >-from builtins_model import BuiltinFunction, BuiltinObject >-from builtins_templates import BuiltinsGeneratorTemplates as Templates >- >-log = logging.getLogger('global') >- >-# These match WK_lcfirst and WK_ucfirst defined in CodeGenerator.pm. >-def WK_lcfirst(str): >- str = str[:1].lower() + str[1:] >- str = str.replace('dOM', 'dom') >- str = str.replace('uRL', 'url') >- str = str.replace('jS', 'js') >- str = str.replace('xML', 'xml') >- str = str.replace('xSLT', 'xslt') >- str = str.replace('cSS', 'css') >- str = str.replace('rTC', 'rtc') >- return str >- >-def WK_ucfirst(str): >- str = str[:1].upper() + str[1:] >- str = str.replace('Xml', 'XML') >- str = str.replace('Svg', 'SVG') >- return str >- >-class BuiltinsGenerator: >- def __init__(self, model): >- self._model = model >- >- def model(self): >- return self._model >- >- # These methods are overridden by subclasses. >- >- def generate_output(self): >- pass >- >- def output_filename(self): >- pass >- >- >- # Shared code generation methods. >- def generate_license(self): >- raw_license = Template(Templates.LicenseText).substitute(None) >- copyrights = self._model.copyrights() >- copyrights.sort() >- >- license_block = [] >- license_block.append("/*") >- for copyright in copyrights: >- license_block.append(" * Copyright (c) %s" % copyright) >- if len(copyrights) > 0: >- license_block.append(" * ") >- >- for line in raw_license.split('\n'): >- license_block.append(" * " + line) >- >- license_block.append(" */") >- >- return '\n'.join(license_block) >- >- def generate_includes_from_entries(self, entries): >- includes = set() >- for entry in entries: >- (allowed_framework_names, data) = entry >- (framework_name, header_path) = data >- >- if self.model().framework.name not in allowed_framework_names: >- continue >- if self.model().framework.name != framework_name: >- includes.add("#include <%s/%s>" % (framework_name, os.path.basename(header_path))) >- else: >- includes.add("#include \"%s\"" % os.path.basename(header_path)) >- >- return sorted(list(includes)) >- >- def generate_primary_header_includes(self): >- name, _ = os.path.splitext(self.output_filename()) >- return '\n'.join([ >- "#include \"config.h\"", >- "#include \"%s.h\"" % name, >- ]) >- >- def generate_embedded_code_string_section_for_function(self, function): >- text = function.function_source >- # Wrap it in parens to avoid adding to global scope. >- text = "(function " + text[text.index("("):] + ")" >- embeddedSourceLength = len(text) + 1 # For extra \n. >- # Lazy way to escape quotes, I think? >- textLines = json.dumps(text)[1:-1].split("\\n") >- # This looks scary because we need the JS source itself to have newlines. >- embeddedSource = '\n'.join([' "%s\\n" \\' % line for line in textLines]) >- >- constructAbility = "CannotConstruct" >- if function.is_constructor: >- constructAbility = "CanConstruct" >- >- args = { >- 'codeName': BuiltinsGenerator.mangledNameForFunction(function) + 'Code', >- 'embeddedSource': embeddedSource, >- 'embeddedSourceLength': embeddedSourceLength, >- 'canConstruct': constructAbility, >- 'intrinsic': function.intrinsic >- } >- >- lines = [] >- lines.append("const JSC::ConstructAbility s_%(codeName)sConstructAbility = JSC::ConstructAbility::%(canConstruct)s;" % args); >- lines.append("const int s_%(codeName)sLength = %(embeddedSourceLength)d;" % args); >- lines.append("static const JSC::Intrinsic s_%(codeName)sIntrinsic = JSC::%(intrinsic)s;" % args); >- lines.append("const char* s_%(codeName)s =\n%(embeddedSource)s\n;" % args); >- return '\n'.join(lines) >- >- # Helper methods. >- >- @staticmethod >- def wrap_with_guard(guard, text): >- if not guard: >- return text >- return '\n'.join([ >- '#if %s' % guard, >- text, >- '#endif // %s' % guard, >- ]) >- >- @staticmethod >- def mangledNameForObject(object): >- if not isinstance(object, BuiltinObject): >- raise Exception("Invalid argument passed to mangledNameForObject()") >- >- def toCamel(match): >- str = match.group(0) >- return str[1].upper() >- return re.sub(r'\.[a-z]', toCamel, object.object_name, flags=re.IGNORECASE) >- >- >- @staticmethod >- def mangledNameForFunction(function): >- if not isinstance(function, BuiltinFunction): >- raise Exception("Invalid argument passed to mangledNameForFunction()") >- >- function_name = WK_ucfirst(function.function_name) >- >- def toCamel(match): >- str = match.group(0) >- return str[1].upper() >- function_name = re.sub(r'\.[a-z]', toCamel, function_name, flags=re.IGNORECASE) >- if function.is_constructor: >- function_name = function_name + "Constructor" >- >- object_name = BuiltinsGenerator.mangledNameForObject(function.object) >- return WK_lcfirst(object_name + function_name) >diff --git a/Source/JavaScriptCore/Scripts/builtins/builtins_model.py b/Source/JavaScriptCore/Scripts/builtins/builtins_model.py >deleted file mode 100755 >index 0519c5eee4cdbcdb5c969d5d8158a324c35fba8b..0000000000000000000000000000000000000000 >--- a/Source/JavaScriptCore/Scripts/builtins/builtins_model.py >+++ /dev/null >@@ -1,306 +0,0 @@ >-#!/usr/bin/env python >-# >-# Copyright (c) 2015-2016 Apple 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: >-# 1. Redistributions of source code must retain the above copyright >-# notice, this list of conditions and the following disclaimer. >-# 2. 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. >-# >-# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 logging >-import re >-import os >- >-from builtins_templates import BuiltinsGeneratorTemplates as Templates >- >-log = logging.getLogger('global') >- >-_FRAMEWORK_CONFIG_MAP = { >- "JavaScriptCore": { >- "macro_prefix": "JSC", >- "namespace": "JSC", >- }, >- "WebCore": { >- "macro_prefix": "WEBCORE", >- "namespace": "WebCore", >- }, >-} >- >-functionHeadRegExp = re.compile(r"(?:@[\w|=\[\] \"\.]+\s*\n)*function\s+\w+\s*\(.*?\)", re.MULTILINE | re.DOTALL) >-functionGlobalPrivateRegExp = re.compile(r".*^@globalPrivate", re.MULTILINE | re.DOTALL) >-functionIntrinsicRegExp = re.compile(r".*^@intrinsic=(\w+)", re.MULTILINE | re.DOTALL) >-functionIsConstructorRegExp = re.compile(r".*^@constructor", re.MULTILINE | re.DOTALL) >-functionIsGetterRegExp = re.compile(r".*^@getter", re.MULTILINE | re.DOTALL) >-functionNameRegExp = re.compile(r"function\s+(\w+)\s*\(", re.MULTILINE | re.DOTALL) >-functionOverriddenNameRegExp = re.compile(r".*^@overriddenName=(\".+\")$", re.MULTILINE | re.DOTALL) >-functionParameterFinder = re.compile(r"^function\s+(?:\w+)\s*\(((?:\s*\w+)?\s*(?:\s*,\s*\w+)*)?\s*\)", re.MULTILINE | re.DOTALL) >- >-multilineCommentRegExp = re.compile(r"\/\*.*?\*\/", re.MULTILINE | re.DOTALL) >-singleLineCommentRegExp = re.compile(r"\/\/.*?\n", re.MULTILINE | re.DOTALL) >-keyValueAnnotationCommentRegExp = re.compile(r"^\/\/ @(\w+)=([^=]+?)\n", re.MULTILINE | re.DOTALL) >-flagAnnotationCommentRegExp = re.compile(r"^\/\/ @(\w+)[^=]*?\n", re.MULTILINE | re.DOTALL) >-lineWithOnlySingleLineCommentRegExp = re.compile(r"^\s*\/\/\n", re.MULTILINE | re.DOTALL) >-lineWithTrailingSingleLineCommentRegExp = re.compile(r"\s*\/\/\n", re.MULTILINE | re.DOTALL) >-leadingWhitespaceRegExp = re.compile(r"^ +", re.MULTILINE | re.DOTALL) >-multipleEmptyLinesRegExp = re.compile(r"\n{2,}", re.MULTILINE | re.DOTALL) >- >-class ParseException(Exception): >- pass >- >- >-class Framework: >- def __init__(self, name): >- self._settings = _FRAMEWORK_CONFIG_MAP[name] >- self.name = name >- >- def setting(self, key, default=''): >- return self._settings.get(key, default) >- >- @staticmethod >- def fromString(frameworkString): >- if frameworkString == "JavaScriptCore": >- return Frameworks.JavaScriptCore >- >- if frameworkString == "WebCore": >- return Frameworks.WebCore >- >- raise ParseException("Unknown framework: %s" % frameworkString) >- >- >-class Frameworks: >- JavaScriptCore = Framework("JavaScriptCore") >- WebCore = Framework("WebCore") >- >- >-class BuiltinObject: >- def __init__(self, object_name, annotations, functions): >- self.object_name = object_name >- self.annotations = annotations >- self.functions = functions >- self.collection = None # Set by the owning BuiltinsCollection >- >- for function in self.functions: >- function.object = self >- >- >-class BuiltinFunction: >- def __init__(self, function_name, function_source, parameters, is_constructor, is_global_private, intrinsic, overridden_name): >- self.function_name = function_name >- self.function_source = function_source >- self.parameters = parameters >- self.is_constructor = is_constructor >- self.is_global_private = is_global_private >- self.intrinsic = intrinsic >- self.overridden_name = overridden_name >- self.object = None # Set by the owning BuiltinObject >- >- @staticmethod >- def fromString(function_string): >- function_source = multilineCommentRegExp.sub("", function_string) >- >- intrinsic = "NoIntrinsic" >- intrinsicMatch = functionIntrinsicRegExp.search(function_source) >- if intrinsicMatch: >- intrinsic = intrinsicMatch.group(1) >- function_source = functionIntrinsicRegExp.sub("", function_source) >- >- overridden_name = None >- overriddenNameMatch = functionOverriddenNameRegExp.search(function_source) >- if overriddenNameMatch: >- overridden_name = overriddenNameMatch.group(1) >- function_source = functionOverriddenNameRegExp.sub("", function_source) >- >- if not os.getenv("CONFIGURATION", "Debug").startswith("Debug"): >- function_source = lineWithOnlySingleLineCommentRegExp.sub("", function_source) >- function_source = lineWithTrailingSingleLineCommentRegExp.sub("\n", function_source) >- function_source = leadingWhitespaceRegExp.sub("", function_source) >- function_source = multipleEmptyLinesRegExp.sub("\n", function_source) >- >- function_name = functionNameRegExp.findall(function_source)[0] >- is_constructor = functionIsConstructorRegExp.match(function_source) != None >- is_getter = functionIsGetterRegExp.match(function_source) != None >- is_global_private = functionGlobalPrivateRegExp.match(function_source) != None >- parameters = [s.strip() for s in functionParameterFinder.findall(function_source)[0].split(',')] >- if len(parameters[0]) == 0: >- parameters = [] >- >- if is_getter and not overridden_name: >- overridden_name = "\"get %s\"" % (function_name) >- >- if not overridden_name: >- overridden_name = "static_cast<const char*>(nullptr)" >- >- return BuiltinFunction(function_name, function_source, parameters, is_constructor, is_global_private, intrinsic, overridden_name) >- >- def __str__(self): >- interface = "%s(%s)" % (self.function_name, ', '.join(self.parameters)) >- if self.is_constructor: >- interface = interface + " [Constructor]" >- >- return interface >- >- >-class BuiltinsCollection: >- def __init__(self, framework_name): >- self._copyright_lines = set() >- self.objects = [] >- self.framework = Framework.fromString(framework_name) >- log.debug("Created new Builtins collection.") >- >- def parse_builtins_file(self, filename, text): >- log.debug("Parsing builtins file: %s" % filename) >- >- parsed_copyrights = set(self._parse_copyright_lines(text)) >- self._copyright_lines = self._copyright_lines.union(parsed_copyrights) >- >- log.debug("Found copyright lines:") >- for line in self._copyright_lines: >- log.debug(line) >- log.debug("") >- >- object_annotations = self._parse_annotations(text) >- >- object_name, ext = os.path.splitext(os.path.basename(filename)) >- log.debug("Parsing object: %s" % object_name) >- >- parsed_functions = self._parse_functions(text) >- for function in parsed_functions: >- function.object = object_name >- >- log.debug("Parsed functions:") >- for func in parsed_functions: >- log.debug(func) >- log.debug("") >- >- new_object = BuiltinObject(object_name, object_annotations, parsed_functions) >- new_object.collection = self >- self.objects.append(new_object) >- >- def copyrights(self): >- owner_to_years = dict() >- copyrightYearRegExp = re.compile(r"(\d{4})[, ]{0,2}") >- ownerStartRegExp = re.compile(r"[^\d, ]") >- >- # Returns deduplicated copyrights keyed on the owner. >- for line in self._copyright_lines: >- years = set(copyrightYearRegExp.findall(line)) >- ownerIndex = ownerStartRegExp.search(line).start() >- owner = line[ownerIndex:] >- log.debug("Found years: %s and owner: %s" % (years, owner)) >- if owner not in owner_to_years: >- owner_to_years[owner] = set() >- >- owner_to_years[owner] = owner_to_years[owner].union(years) >- >- result = [] >- >- for owner, years in owner_to_years.items(): >- sorted_years = list(years) >- sorted_years.sort() >- result.append("%s %s" % (', '.join(sorted_years), owner)) >- >- return result >- >- def all_functions(self): >- result = [] >- for object in self.objects: >- result.extend(object.functions) >- >- result.sort() >- return result >- >- def all_internal_functions(self): >- result = [] >- for object in [o for o in self.objects if 'internal' in o.annotations]: >- result.extend(object.functions) >- >- result.sort() >- return result >- >- # Private methods. >- >- def _parse_copyright_lines(self, text): >- licenseBlock = multilineCommentRegExp.findall(text)[0] >- licenseBlock = licenseBlock[:licenseBlock.index("Redistribution")] >- >- copyrightLines = [Templates.DefaultCopyright] >- for line in licenseBlock.split("\n"): >- line = line.replace("/*", "") >- line = line.replace("*/", "") >- line = line.replace("*", "") >- line = line.replace("Copyright", "") >- line = line.replace("copyright", "") >- line = line.replace("(C)", "") >- line = line.replace("(c)", "") >- line = line.strip() >- >- if len(line) == 0: >- continue >- >- copyrightLines.append(line) >- >- return copyrightLines >- >- def _parse_annotations(self, text): >- annotations = {} >- >- for match in keyValueAnnotationCommentRegExp.finditer(text): >- (key, value) = match.group(1, 2) >- log.debug("Found annotation: '%s' => '%s'" % (key, value)) >- if key in annotations: >- raise ParseException("Duplicate annotation found: %s" % key) >- >- annotations[key] = value >- >- for match in flagAnnotationCommentRegExp.finditer(text): >- key = match.group(1) >- log.debug("Found annotation: '%s' => 'TRUE'" % key) >- if key in annotations: >- raise ParseException("Duplicate annotation found: %s" % key) >- >- annotations[key] = True >- >- return annotations >- >- def _parse_functions(self, text): >- text = multilineCommentRegExp.sub("/**/", singleLineCommentRegExp.sub("//\n", text)) >- >- matches = [func for func in functionHeadRegExp.finditer(text)] >- functionBounds = [] >- start = 0 >- end = 0 >- for match in matches: >- start = match.start() >- if start < end: >- continue >- end = match.end() >- while text[end] != '{': >- end = end + 1 >- depth = 1 >- end = end + 1 >- while depth > 0: >- if text[end] == '{': >- depth = depth + 1 >- elif text[end] == '}': >- depth = depth - 1 >- end = end + 1 >- functionBounds.append((start, end)) >- >- functionStrings = [text[start:end].strip() for (start, end) in functionBounds] >- return map(BuiltinFunction.fromString, functionStrings) >diff --git a/Source/JavaScriptCore/Scripts/builtins/builtins_templates.py b/Source/JavaScriptCore/Scripts/builtins/builtins_templates.py >deleted file mode 100644 >index 907a6d717c910cb07299509c61df846a9c701efc..0000000000000000000000000000000000000000 >--- a/Source/JavaScriptCore/Scripts/builtins/builtins_templates.py >+++ /dev/null >@@ -1,216 +0,0 @@ >-#!/usr/bin/env python >-# >-# Copyright (c) 2014-2016 Apple Inc. All rights reserved. >-# Copyright (C) 2015 Canon 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: >-# 1. Redistributions of source code must retain the above copyright >-# notice, this list of conditions and the following disclaimer. >-# 2. 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. >-# >-# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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. >- >-# Builtins generator templates, which can be filled with string.Template. >- >- >-class BuiltinsGeneratorTemplates: >- >- DefaultCopyright = "2016 Apple Inc. All rights reserved." >- LicenseText = ( >- """Redistribution and use in source and binary forms, with or without >-modification, are permitted provided that the following conditions >-are met: >-1. Redistributions of source code must retain the above copyright >- notice, this list of conditions and the following disclaimer. >-2. 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. >- >-THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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. >-""") >- >- DoNotEditWarning = ( >- """// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for >-// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py""") >- >- HeaderIncludeGuard = ( >- """#pragma once""") >- >- NamespaceTop = ( >- """namespace ${namespace} {""") >- >- NamespaceBottom = ( >- """} // namespace ${namespace}""") >- >- CombinedHeaderStaticMacros = ( >- """#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\ >- JSC::FunctionExecutable* codeName##Generator(JSC::VM&); >- >-${macroPrefix}_FOREACH_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR) >-#undef DECLARE_BUILTIN_GENERATOR""") >- >- SeparateHeaderStaticMacros = ( >- """#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\ >- JSC::FunctionExecutable* codeName##Generator(JSC::VM&); >- >-${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR) >-#undef DECLARE_BUILTIN_GENERATOR""") >- >- CombinedJSCImplementationStaticMacros = ( >- """ >-#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\ >-JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \\ >-{\\ >- return vm.builtinExecutables()->codeName##Executable()->link(vm, vm.builtinExecutables()->codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \ >-} >-${macroPrefix}_FOREACH_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) >-#undef DEFINE_BUILTIN_GENERATOR >-""") >- >- SeparateJSCImplementationStaticMacros = ( >- """ >-#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\ >-JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \\ >-{\\ >- return vm.builtinExecutables()->codeName##Executable()->link(vm, vm.builtinExecutables()->codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \ >-} >-${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) >-#undef DEFINE_BUILTIN_GENERATOR >-""") >- >- CombinedWebCoreImplementationStaticMacros = ( >- """ >-#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\ >-JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \\ >-{\\ >- JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \\ >- return clientData->builtinFunctions().${objectNameLC}Builtins().codeName##Executable()->link(vm, clientData->builtinFunctions().${objectNameLC}Builtins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \\ >-} >-${macroPrefix}_FOREACH_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) >-#undef DEFINE_BUILTIN_GENERATOR >-""") >- >- SeparateWebCoreImplementationStaticMacros = ( >- """ >-#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\ >-JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \\ >-{\\ >- JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \\ >- return clientData->builtinFunctions().${objectNameLC}Builtins().codeName##Executable()->link(vm, clientData->builtinFunctions().${objectNameLC}Builtins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \\ >-} >-${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) >-#undef DEFINE_BUILTIN_GENERATOR >-""") >- >- SeparateHeaderWrapperBoilerplate = ( >- """class ${objectName}BuiltinsWrapper : private JSC::WeakHandleOwner { >-public: >- explicit ${objectName}BuiltinsWrapper(JSC::VM* vm) >- : m_vm(*vm) >- ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES) >-#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { })) >- ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS) >-#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS >- { >- } >- >-#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \\ >- JSC::UnlinkedFunctionExecutable* name##Executable(); \\ >- const JSC::SourceCode& name##Source() const { return m_##name##Source; } >- ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES) >-#undef EXPOSE_BUILTIN_EXECUTABLES >- >- ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) >- >- void exportNames(); >- >-private: >- JSC::VM& m_vm; >- >- ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES) >- >-#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \\ >- JSC::SourceCode m_##name##Source;\\ >- JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable; >- ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS) >-#undef DECLARE_BUILTIN_SOURCE_MEMBERS >- >-}; >- >-#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \\ >-inline JSC::UnlinkedFunctionExecutable* ${objectName}BuiltinsWrapper::name##Executable() \\ >-{\\ >- if (!m_##name##Executable) {\\ >- JSC::Identifier executableName = functionName##PublicName();\\ >- if (overriddenName)\\ >- executableName = JSC::Identifier::fromString(&m_vm, overriddenName);\\ >- m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructAbility), this, &m_##name##Executable);\\ >- }\\ >- return m_##name##Executable.get();\\ >-} >-${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES) >-#undef DEFINE_BUILTIN_EXECUTABLES >- >-inline void ${objectName}BuiltinsWrapper::exportNames() >-{ >-#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName()); >- ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME) >-#undef EXPORT_FUNCTION_NAME >-}""") >- >- SeparateHeaderInternalFunctionsBoilerplate = ( >- """class ${objectName}BuiltinFunctions { >-public: >- explicit ${objectName}BuiltinFunctions(JSC::VM& vm) : m_vm(vm) { } >- >- void init(JSC::JSGlobalObject&); >- void visit(JSC::SlotVisitor&); >- >-public: >- JSC::VM& m_vm; >- >-#define DECLARE_BUILTIN_SOURCE_MEMBERS(functionName) \\ >- JSC::WriteBarrier<JSC::JSFunction> m_##functionName##Function; >- ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_SOURCE_MEMBERS) >-#undef DECLARE_BUILTIN_SOURCE_MEMBERS >-}; >- >-inline void ${objectName}BuiltinFunctions::init(JSC::JSGlobalObject& globalObject) >-{ >-#define EXPORT_FUNCTION(codeName, functionName, overriddenName, length)\\ >- m_##functionName##Function.set(m_vm, &globalObject, JSC::JSFunction::create(m_vm, codeName##Generator(m_vm), &globalObject)); >- ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(EXPORT_FUNCTION) >-#undef EXPORT_FUNCTION >-} >- >-inline void ${objectName}BuiltinFunctions::visit(JSC::SlotVisitor& visitor) >-{ >-#define VISIT_FUNCTION(name) visitor.append(m_##name##Function); >- ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_FUNCTION_NAME(VISIT_FUNCTION) >-#undef VISIT_FUNCTION >-} >-""") >diff --git a/Source/JavaScriptCore/Scripts/cssmin.py b/Source/JavaScriptCore/Scripts/cssmin.py >index c34cd081b94daecadbc28c7a2816b0c0bd23c156..c4c8f29af8ecce6768d4bac0855667fcd50336ed 100644 >--- a/Source/JavaScriptCore/Scripts/cssmin.py >+++ b/Source/JavaScriptCore/Scripts/cssmin.py >@@ -46,4 +46,7 @@ if __name__ == "__main__": > if sys.version_info[0] == 3 and sys.stdin.encoding != 'UTF-8': > import io > sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='UTF-8') >+ if sys.version_info[0] == 3 and sys.stdout.encoding != 'UTF-8': >+ import io >+ sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='UTF-8') > sys.stdout.write(cssminify(sys.stdin.read())) >diff --git a/Source/JavaScriptCore/Scripts/generate-js-builtins.py b/Source/JavaScriptCore/Scripts/generate-js-builtins.py >index c3e498a95eb2aef5e6bfbd7408e392936f786048..51b101649218c566449250ee0bcaa960a715cb6f 100644 >--- a/Source/JavaScriptCore/Scripts/generate-js-builtins.py >+++ b/Source/JavaScriptCore/Scripts/generate-js-builtins.py >@@ -31,14 +31,14 @@ import fnmatch > import logging > import optparse > import os >+import sys > > logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.ERROR) > log = logging.getLogger('global') > > from lazywriter import LazyFileWriter > >-from builtins import * >- >+from wkbuiltins import * > > def concatenated_output_filename(builtins_files, framework_name, generate_only_wrapper_files): > if generate_only_wrapper_files: >@@ -46,6 +46,12 @@ def concatenated_output_filename(builtins_files, framework_name, generate_only_w > return os.path.basename(builtins_files[0]) + '-result' > > >+def doopen(file, mode): >+ if sys.version_info.major == 2: >+ return open(file, mode) >+ else: >+ return open(file, mode, encoding="UTF-8") >+ > def generate_bindings_for_builtins_files(builtins_files=[], > output_path=None, > concatenate_output=False, >@@ -59,7 +65,7 @@ def generate_bindings_for_builtins_files(builtins_files=[], > model = BuiltinsCollection(framework_name=framework_name) > > for filepath in builtins_files: >- with open(filepath, "r") as file: >+ with doopen(filepath, "r") as file: > file_text = file.read() > file_name = os.path.basename(filepath) > >@@ -146,7 +152,7 @@ if __name__ == '__main__': > for filepath in os.listdir(arg_options.input_directory): > input_filepaths.append(os.path.join(arg_options.input_directory, filepath)) > >- input_filepaths = sorted(filter(lambda name: fnmatch.fnmatch(name, '*.js'), input_filepaths)) >+ input_filepaths = sorted([name for name in input_filepaths if fnmatch.fnmatch(name, '*.js')]) > > options = { > 'output_path': arg_options.output_directory, >@@ -159,7 +165,7 @@ if __name__ == '__main__': > > log.debug("Generating code for builtins.") > log.debug("Parsed options:") >- for option, value in options.items(): >+ for option, value in list(options.items()): > log.debug(" %s: %s" % (option, value)) > log.debug("") > log.debug("Input files:") >diff --git a/Source/JavaScriptCore/Scripts/generateIntlCanonicalizeLanguage.py b/Source/JavaScriptCore/Scripts/generateIntlCanonicalizeLanguage.py >index 69f3be837ccead3d20f9b476b0fb2a387696f6c0..b9a028a6004c7ea7b2e0bbd31e94f59f98e42041 100644 >--- a/Source/JavaScriptCore/Scripts/generateIntlCanonicalizeLanguage.py >+++ b/Source/JavaScriptCore/Scripts/generateIntlCanonicalizeLanguage.py >@@ -50,6 +50,13 @@ def openOrExit(path, mode): > exit(1) > > >+def dowrite(file, str): >+ if sys.version_info.major == 2: >+ file.write(str) >+ else: >+ file.write(bytes(str, "utf-8")) >+ >+ > class SubtagRegistry: > def __init__(self): > self.languageMap = {} >@@ -109,43 +116,43 @@ class SubtagRegistry: > > def dump(self, file): > if self.fileDate: >- file.write("// language-subtag-registry file date: {}\n".format(self.fileDate)) >- file.write("\n#pragma once\n") >- file.write("\n#if ENABLE(INTL)\n") >- file.write("\nnamespace JSC {\n") >+ dowrite(file, "// language-subtag-registry file date: {}\n".format(self.fileDate)) >+ dowrite(file, "\n#pragma once\n") >+ dowrite(file, "\n#if ENABLE(INTL)\n") >+ dowrite(file, "\nnamespace JSC {\n") > self.dumpLookup(file, "intlPreferredLanguageTag", self.languageMap) > self.dumpLookup(file, "intlPreferredExtlangTag", self.extlangMap) > self.dumpLookup(file, "intlPreferredRegionTag", self.regionMap) > self.dumpLookup(file, "intlRedundantLanguageTag", self.redundantMap) > self.dumpLookup(file, "intlGrandfatheredLanguageTag", self.grandfatheredMap) >- file.write("\n} // namespace JSC\n") >- file.write("\n#endif // ENABLE(INTL)\n") >+ dowrite(file, "\n} // namespace JSC\n") >+ dowrite(file, "\n#endif // ENABLE(INTL)\n") > > def dumpLookup(self, file, name, map): >- file.write("\nstatic String {}(const String& tag)\n{{\n".format(name)) >- file.write(" // {} possible replacements\n".format(len(map))) >+ dowrite(file, "\nstatic String {}(const String& tag)\n{{\n".format(name)) >+ dowrite(file, " // {} possible replacements\n".format(len(map))) > # We could pick the lookup implementation per map if desired > # Anecdotal perf: if > switch > hash (slowest) > # Code complexity: switch > if > hash (least complex) > # Algo complexity: if = O(N) > switch > O(log N) > hash = O(1) (least complex) > self.dumpIfLookup(file, name, map) >- file.write("}\n") >+ dowrite(file, "}\n") > > def dumpHashLookup(self, file, name, map): >- file.write(" static NeverDestroyed<HashMap<String, String>> cache;\n") >- file.write(" HashMap<String, String>& map = cache.get();\n") >- file.write(" if (UNLIKELY(map.isEmpty())) {\n") >+ dowrite(file, " static NeverDestroyed<HashMap<String, String>> cache;\n") >+ dowrite(file, " HashMap<String, String>& map = cache.get();\n") >+ dowrite(file, " if (UNLIKELY(map.isEmpty())) {\n") > entries = [" map.add(\"{}\"_s, \"{}\"_s);\n".format(k, v) for k, v in map.items()] > entries.sort() >- file.write("".join(entries)) >- file.write(" }\n") >- file.write(" return map.get(tag);\n") >+ dowrite(file, "".join(entries)) >+ dowrite(file, " }\n") >+ dowrite(file, " return map.get(tag);\n") > > def dumpIfLookup(self, file, name, map): > entries = [" if (tag == \"{}\")\n return \"{}\"_s;".format(k, v) for k, v in map.items()] > entries.sort() >- file.write("\n".join(entries)) >- file.write("\n return String();\n") >+ dowrite(file, "\n".join(entries)) >+ dowrite(file, "\n return String();\n") > > def dumpSwitchLookup(self, file, name, map): > tree = {} >@@ -157,25 +164,25 @@ class SubtagRegistry: > node = node[char] > node["value"] = v > self.dumpSwitchLookupTree(file, tree, 0) >- file.write("\n return String();\n") >+ dowrite(file, "\n return String();\n") > > def dumpSwitchLookupTree(self, file, tree, level): > indent = "".ljust((level + 1) * 4) > if "value" in tree: >- file.write(indent + "if (tag.length() == {})\n".format(level)) >- file.write(indent + " return \"{}\"_s;\n".format(tree["value"])) >+ dowrite(file, indent + "if (tag.length() == {})\n".format(level)) >+ dowrite(file, indent + " return \"{}\"_s;\n".format(tree["value"])) > del tree["value"] > keys = tree.keys() > keys.sort() > if len(keys) == 0: > return >- file.write(indent + "switch (tag[{}]) {{\n".format(level)) >+ dowrite(file, indent + "switch (tag[{}]) {{\n".format(level)) > for key in keys: >- file.write(indent + "case {}:\n".format(ord(key))) >+ dowrite(file, indent + "case {}:\n".format(ord(key))) > self.dumpSwitchLookupTree(file, tree[key], level + 1) >- file.write(indent + " break;\n") >- file.write(indent + "default: break;\n") >- file.write(indent + "}\n") >+ dowrite(file, indent + " break;\n") >+ dowrite(file, indent + "default: break;\n") >+ dowrite(file, indent + "}\n") > > > if __name__ == "__main__": >@@ -191,12 +198,12 @@ if __name__ == "__main__": > registryFile = openOrExit(registryPath, "r") > intlCanonHFile = openOrExit(intlCanonHPath, "wb") > >- intlCanonHFile.write(header) >+ dowrite(intlCanonHFile, header) > > registry = SubtagRegistry() > registry.parse(registryFile) > registry.dump(intlCanonHFile) > >- intlCanonHFile.write(footer) >+ dowrite(intlCanonHFile, footer) > > exit(0) >diff --git a/Source/JavaScriptCore/Scripts/generateYarrUnicodePropertyTables.py b/Source/JavaScriptCore/Scripts/generateYarrUnicodePropertyTables.py >index f8bc6805d70c31aeb8d15b241df5607c05b607b8..c61a773575c6793c41888367ba9bcdbc82d22262 100644 >--- a/Source/JavaScriptCore/Scripts/generateYarrUnicodePropertyTables.py >+++ b/Source/JavaScriptCore/Scripts/generateYarrUnicodePropertyTables.py >@@ -90,7 +90,10 @@ aliases = None > > def openOrExit(path, mode): > try: >- return open(path, mode) >+ if sys.version_info.major == 2 or mode == "wb" or mode == "rb": >+ return open(path, mode) >+ else: >+ return open(path, mode, encoding = "UTF-8") > except IOError as e: > print("I/O error opening {0}, ({1}): {2}".format(path, e.errno, e.strerror)) > exit(1) >@@ -215,6 +218,13 @@ class Aliases: > return self.aliasToScript[name] > > >+def dowrite(file, str): >+ if sys.version_info.major == 2: >+ file.write(str) >+ else: >+ file.write(bytes(str, "utf-8")) >+ >+ > class PropertyData: > allPropertyData = [] > >@@ -322,7 +332,7 @@ class PropertyData: > insertLocation = None > lowCodePoint = None > highCodePoint = None >- for idx in xrange(len(matches)): >+ for idx in range(len(matches)): > match = matches[idx] > if codePoint == match + 1: > lowCodePoint = match >@@ -351,22 +361,22 @@ class PropertyData: > lowCodePoint = codePoint > highCodePoint = codePoint > >- for idx in xrange(len(ranges)): >- range = ranges[idx] >- if lowCodePoint >= range[0] and highCodePoint <= range[1]: >+ for idx in range(len(ranges)): >+ cur_range = ranges[idx] >+ if lowCodePoint >= cur_range[0] and highCodePoint <= cur_range[1]: > return >- if lowCodePoint <= (range[1] + 1) and highCodePoint >= (range[0] - 1): >+ if lowCodePoint <= (cur_range[1] + 1) and highCodePoint >= (cur_range[0] - 1): > while idx < len(ranges) and highCodePoint >= (ranges[idx][0] - 1): >- range = ranges[idx] >- lowCodePoint = min(lowCodePoint, range[0]) >- highCodePoint = max(highCodePoint, range[1]) >+ cur_range = ranges[idx] >+ lowCodePoint = min(lowCodePoint, cur_range[0]) >+ highCodePoint = max(highCodePoint, cur_range[1]) > del ranges[idx] >- self.codePointCount = self.codePointCount - (range[1] - range[0]) - 1 >+ self.codePointCount = self.codePointCount - (cur_range[1] - cur_range[0]) - 1 > > ranges.insert(idx, (lowCodePoint, highCodePoint)) > self.codePointCount = self.codePointCount + (highCodePoint - lowCodePoint) + 1 > return >- elif highCodePoint < range[0]: >+ elif highCodePoint < cur_range[0]: > if lowCodePoint != highCodePoint: > ranges.insert(idx, (lowCodePoint, highCodePoint)) > self.codePointCount = self.codePointCount + (highCodePoint - lowCodePoint) + 1 >@@ -384,7 +394,7 @@ class PropertyData: > > def addRangeUnorderedForMatchesAndRanges(self, lowCodePoint, highCodePoint, matches, ranges): > if len(matches) and highCodePoint >= matches[0] and lowCodePoint <= matches[-1]: >- for idx in xrange(len(matches)): >+ for idx in range(len(matches)): > match = matches[idx] > if lowCodePoint <= match and highCodePoint >= match: > while idx < len(matches) and highCodePoint >= matches[idx]: >@@ -414,22 +424,22 @@ class PropertyData: > elif highCodePoint < match: > break > >- for idx in xrange(len(ranges)): >- range = ranges[idx] >- if lowCodePoint >= range[0] and highCodePoint <= range[1]: >+ for idx in range(len(ranges)): >+ cur_range = ranges[idx] >+ if lowCodePoint >= cur_range[0] and highCodePoint <= cur_range[1]: > return >- if lowCodePoint <= (range[1] + 1) and highCodePoint >= (range[0] - 1): >+ if lowCodePoint <= (cur_range[1] + 1) and highCodePoint >= (cur_range[0] - 1): > while idx < len(ranges) and highCodePoint >= (ranges[idx][0] - 1): >- range = ranges[idx] >- lowCodePoint = min(lowCodePoint, range[0]) >- highCodePoint = max(highCodePoint, range[1]) >+ cur_range = ranges[idx] >+ lowCodePoint = min(lowCodePoint, cur_range[0]) >+ highCodePoint = max(highCodePoint, cur_range[1]) > del ranges[idx] >- self.codePointCount = self.codePointCount - (range[1] - range[0]) - 1 >+ self.codePointCount = self.codePointCount - (cur_range[1] - cur_range[0]) - 1 > > ranges.insert(idx, (lowCodePoint, highCodePoint)) > self.codePointCount = self.codePointCount + (highCodePoint - lowCodePoint) + 1 > return >- elif highCodePoint < range[0]: >+ elif highCodePoint < cur_range[0]: > ranges.insert(idx, (lowCodePoint, highCodePoint)) > self.codePointCount = self.codePointCount + (highCodePoint - lowCodePoint) + 1 > return >@@ -459,13 +469,13 @@ class PropertyData: > self.addRangeUnorderedForMatchesAndRanges(firstUnicodeCodePoint, highCodePoint, self.unicodeMatches, self.unicodeRanges) > > def removeMatchFromRanges(self, codePoint, ranges): >- for idx in xrange(len(ranges)): >- range = ranges[idx] >- if range[0] <= codePoint and codePoint <= range[1]: >+ for idx in range(len(ranges)): >+ cur_range = ranges[idx] >+ if cur_range[0] <= codePoint and codePoint <= cur_range[1]: > ranges.pop(idx) >- if range[0] < codePoint and codePoint < range[1]: >- lowRange = (range[0], codePoint - 1) >- highRange = (codePoint + 1, range[1]) >+ if cur_range[0] < codePoint and codePoint < cur_range[1]: >+ lowRange = (cur_range[0], codePoint - 1) >+ highRange = (codePoint + 1, cur_range[1]) > # Since list.insert inserts before the index given, handle the high range first > if highRange[0] == highRange[1]: > self.addMatchUnordered(highRange[0]) >@@ -476,14 +486,14 @@ class PropertyData: > else: > ranges.insert(idx, lowRange) > else: >- if range[0] == codePoint: >- range = (codePoint + 1, range[1]) >+ if cur_range[0] == codePoint: >+ cur_range = (codePoint + 1, cur_range[1]) > else: >- range = (range[0], codePoint - 1) >- if range[0] == range[1]: >- self.addMatchUnordered(range[0]) >+ cur_range = (cur_range[0], codePoint - 1) >+ if cur_range[0] == cur_range[1]: >+ self.addMatchUnordered(cur_range[0]) > else: >- ranges.insert(idx, range) >+ ranges.insert(idx, cur_range) > self.codePointCount = self.codePointCount - 1 > return > >@@ -505,59 +515,59 @@ class PropertyData: > valuesThisLine = 0 > firstValue = True > >- file.write("{") >+ dowrite(file, "{") > for elem in dataList: > if firstValue: > firstValue = False > else: >- file.write(", ") >+ dowrite(file, ", ") > valuesThisLine = valuesThisLine + 1 > if valuesThisLine > valuesPerLine: >- file.write("\n ") >+ dowrite(file, "\n ") > valuesThisLine = 1 > formatter(file, elem) >- file.write("}") >+ dowrite(file, "}") > > def dump(self, file, commaAfter): >- file.write("static std::unique_ptr<CharacterClass> {}()\n{{\n".format(self.getCreateFuncName())) >- file.write(" // Name = {}, number of codePoints: {}\n".format(self.name, self.codePointCount)) >- file.write(" auto characterClass = std::make_unique<CharacterClass>(\n") >- file.write(" std::initializer_list<UChar32>(") >- self.dumpMatchData(file, 8, self.matches, lambda file, match: (file.write("{0:0=#4x}".format(match)))) >- file.write("),\n") >- file.write(" std::initializer_list<CharacterRange>(") >- self.dumpMatchData(file, 4, self.ranges, lambda file, range: (file.write("{{{0:0=#4x}, {1:0=#4x}}}".format(range[0], range[1])))) >- file.write("),\n") >- file.write(" std::initializer_list<UChar32>(") >- self.dumpMatchData(file, 8, self.unicodeMatches, lambda file, match: (file.write("{0:0=#6x}".format(match)))) >- file.write("),\n") >- file.write(" std::initializer_list<CharacterRange>(") >- self.dumpMatchData(file, 4, self.unicodeRanges, lambda file, range: (file.write("{{{0:0=#6x}, {1:0=#6x}}}".format(range[0], range[1])))) >- file.write("));\n") >- >- file.write(" characterClass->m_hasNonBMPCharacters = {};\n".format(("false", "true")[self.hasNonBMPCharacters])) >- file.write(" return characterClass;\n}\n\n") >+ dowrite(file, "static std::unique_ptr<CharacterClass> {}()\n{{\n".format(self.getCreateFuncName())) >+ dowrite(file, " // Name = {}, number of codePoints: {}\n".format(self.name, self.codePointCount)) >+ dowrite(file, " auto characterClass = std::make_unique<CharacterClass>(\n") >+ dowrite(file, " std::initializer_list<UChar32>(") >+ self.dumpMatchData(file, 8, self.matches, lambda file, match: (dowrite(file, "{0:0=#4x}".format(match)))) >+ dowrite(file, "),\n") >+ dowrite(file, " std::initializer_list<CharacterRange>(") >+ self.dumpMatchData(file, 4, self.ranges, lambda file, range: (dowrite(file, "{{{0:0=#4x}, {1:0=#4x}}}".format(range[0], range[1])))) >+ dowrite(file, "),\n") >+ dowrite(file, " std::initializer_list<UChar32>(") >+ self.dumpMatchData(file, 8, self.unicodeMatches, lambda file, match: (dowrite(file, "{0:0=#6x}".format(match)))) >+ dowrite(file, "),\n") >+ dowrite(file, " std::initializer_list<CharacterRange>(") >+ self.dumpMatchData(file, 4, self.unicodeRanges, lambda file, range: (dowrite(file, "{{{0:0=#6x}, {1:0=#6x}}}".format(range[0], range[1])))) >+ dowrite(file, "));\n") >+ >+ dowrite(file, " characterClass->m_hasNonBMPCharacters = {};\n".format(("false", "true")[self.hasNonBMPCharacters])) >+ dowrite(file, " return characterClass;\n}\n\n") > > @classmethod > def dumpAll(cls, file): > for propertyData in cls.allPropertyData: > propertyData.dump(file, propertyData != cls.allPropertyData[-1]) > >- file.write("typedef std::unique_ptr<CharacterClass> (*CreateCharacterClass)();\n") >- file.write("static CreateCharacterClass createFunctions[{}] = {{\n ".format(len(cls.allPropertyData))) >+ dowrite(file, "typedef std::unique_ptr<CharacterClass> (*CreateCharacterClass)();\n") >+ dowrite(file, "static CreateCharacterClass createFunctions[{}] = {{\n ".format(len(cls.allPropertyData))) > functionsOnThisLine = 0 > for propertyData in cls.allPropertyData: >- file.write(" {},".format(propertyData.getCreateFuncName())) >+ dowrite(file, " {},".format(propertyData.getCreateFuncName())) > functionsOnThisLine = functionsOnThisLine + 1 > if functionsOnThisLine == 4: >- file.write("\n ") >+ dowrite(file, "\n ") > functionsOnThisLine = 0 > >- file.write("};\n\n") >+ dowrite(file, "};\n\n") > > @classmethod > def createAndDumpHashTable(self, file, propertyDict, tablePrefix): >- propertyKeys = propertyDict.keys() >+ propertyKeys = list(propertyDict.keys()) > numberOfKeys = len(propertyKeys) > hashSize = ceilingToPowerOf2(numberOfKeys * 2) > hashMask = hashSize - 1 >@@ -587,7 +597,7 @@ class PropertyData: > hashTable[hash] = (len(valueTable), None) > valueTable.append((key, keyValue[1])) > >- file.write("static const struct HashIndex {}TableIndex[{}] = {{\n".format(tablePrefix, len(hashTable))) >+ dowrite(file, "static const struct HashIndex {}TableIndex[{}] = {{\n".format(tablePrefix, len(hashTable))) > > for tableIndex in hashTable: > value = -1 >@@ -597,17 +607,17 @@ class PropertyData: > if tableIndex[1] is not None: > next = tableIndex[1] > >- file.write(" {{ {}, {} }},\n".format(value, next)) >+ dowrite(file, " {{ {}, {} }},\n".format(value, next)) > >- file.write("};\n\n") >+ dowrite(file, "};\n\n") > >- file.write("static const struct HashValue {}TableValue[{}] = {{\n".format(tablePrefix, len(valueTable))) >+ dowrite(file, "static const struct HashValue {}TableValue[{}] = {{\n".format(tablePrefix, len(valueTable))) > for value in valueTable: >- file.write(" {{ \"{}\", {} }},\n".format(value[0], value[1])) >- file.write("};\n\n") >+ dowrite(file, " {{ \"{}\", {} }},\n".format(value[0], value[1])) >+ dowrite(file, "};\n\n") > >- file.write("static const struct HashTable {}HashTable = \n".format(tablePrefix)) >- file.write(" {{ {}, {}, {}TableValue, {}TableIndex }};\n\n".format(len(valueTable), hashMask, tablePrefix, tablePrefix)) >+ dowrite(file, "static const struct HashTable {}HashTable = \n".format(tablePrefix)) >+ dowrite(file, " {{ {}, {}, {}TableValue, {}TableIndex }};\n\n".format(len(valueTable), hashMask, tablePrefix, tablePrefix)) > > > class Scripts: >@@ -742,21 +752,21 @@ class Scripts: > lowCodePoint = int(codePoints[:dotDot], 16) > highCodePoint = int(codePoints[dotDot + 2:], 16) > currentPropertyData.addRange(lowCodePoint, highCodePoint) >- for codePoint in xrange(lowCodePoint, highCodePoint + 1): >+ for codePoint in range(lowCodePoint, highCodePoint + 1): > commonScriptExtenstionPropertyData.removeMatch(codePoint) > inheritedScriptExtensionPropertyData.removeMatch(codePoint) > > # For the scripts that don't have any additional extension codePoints, copy the script > # data to the script extension with the same name >- for scriptName, propertyData in self.scriptsByName.iteritems(): >+ for scriptName, propertyData in self.scriptsByName.items(): > if scriptName not in self.scriptExtensionsByName: > self.scriptExtensionsByName[scriptName] = propertyData > > def dump(self, file): >- file.write("// Scripts:\n") >+ dowrite(file, "// Scripts:\n") > PropertyData.createAndDumpHashTable(file, self.scriptsByName, "script") > >- file.write("// Script_Extensions:\n") >+ dowrite(file, "// Script_Extensions:\n") > PropertyData.createAndDumpHashTable(file, self.scriptExtensionsByName, "scriptExtension") > > >@@ -877,7 +887,7 @@ class GeneralCategory: > propertyDatas[1].addRange(self.lastAddedCodePoint + 1, MaxUnicode) > > def dump(self, file): >- file.write("// General_Category:\n") >+ dowrite(file, "// General_Category:\n") > PropertyData.createAndDumpHashTable(file, self.propertyDataByCategory, "generalCategory") > > >@@ -920,7 +930,7 @@ class BinaryProperty: > currentPropertyData.addRange(int(codePoints[:dotDot], 16), int(codePoints[dotDot + 2:], 16)) > > def dump(self, file): >- file.write("// binary properties:\n") >+ dowrite(file, "// binary properties:\n") > PropertyData.createAndDumpHashTable(file, self.propertyDataByProperty, "binaryProperty") > > if __name__ == "__main__": >@@ -950,7 +960,7 @@ if __name__ == "__main__": > > propertyDataHFile = openOrExit(unicodeProertyDataHPath, "wb") > >- propertyDataHFile.write(header) >+ dowrite(propertyDataHFile, header) > > aliases.parsePropertyAliasesFile(propertyAliasesFile) > aliases.parsePropertyValueAliasesFile(propertyValueAliasesFile) >@@ -974,6 +984,6 @@ if __name__ == "__main__": > binaryProperty.dump(propertyDataHFile) > scripts.dump(propertyDataHFile) > >- propertyDataHFile.write(footer) >+ dowrite(propertyDataHFile, footer) > > exit(0) >diff --git a/Source/JavaScriptCore/Scripts/hasher.py b/Source/JavaScriptCore/Scripts/hasher.py >index cf0290b5e5e5f6640b33d8c441d7d6f44d9d8e89..d9ba4d0f90fbc0f16d141fa18a8fd171e1514d91 100644 >--- a/Source/JavaScriptCore/Scripts/hasher.py >+++ b/Source/JavaScriptCore/Scripts/hasher.py >@@ -36,7 +36,7 @@ def stringHash(str): > hash = stringHashingStartValue > > strLength = len(str) >- characterPairs = strLength / 2 >+ characterPairs = int(strLength / 2) > remainder = strLength & 1 > > # Main loop >diff --git a/Source/JavaScriptCore/Scripts/jsmin.py b/Source/JavaScriptCore/Scripts/jsmin.py >index 372418b4d2b0a3c6fac362517d69ac9c7b099668..fc647c79f37464820636ad683b963866cd21080f 100644 >--- a/Source/JavaScriptCore/Scripts/jsmin.py >+++ b/Source/JavaScriptCore/Scripts/jsmin.py >@@ -79,10 +79,13 @@ class JavascriptMinify(object): > def write(char): > # all of this is to support literal regular expressions. > # sigh >- if char in 'return': >+ if str(char) in 'return': > self.return_buf += char > self.is_return = self.return_buf == 'return' >- self.outs.write(char) >+ if sys.version_info.major == 2: >+ self.outs.write(char) >+ else: >+ self.outs.write(str(char)) > if self.is_return: > self.return_buf = '' > >@@ -118,8 +121,8 @@ class JavascriptMinify(object): > write(previous) > elif not previous: > return >- elif previous >= '!': >- if previous in "'\"": >+ elif str(previous) >= "!": >+ if str(previous) in "'\"": > in_quote = previous > write(previous) > previous_non_space = previous >@@ -166,7 +169,7 @@ class JavascriptMinify(object): > if numslashes % 2 == 0: > in_quote = '' > write(''.join(quote_buf)) >- elif next1 in '\r\n': >+ elif str(next1) in '\r\n': > if previous_non_space in newlineend_strings \ > or previous_non_space > '~': > while 1: >@@ -179,7 +182,7 @@ class JavascriptMinify(object): > or next2 > '~' or next2 == '/': > do_newline = True > break >- elif next1 < '!' and not in_re: >+ elif str(next1) < '!' and not in_re: > if (previous_non_space in space_strings \ > or previous_non_space > '~') \ > and (next2 in space_strings or next2 > '~'): >@@ -217,14 +220,14 @@ class JavascriptMinify(object): > do_newline = False > > write(next1) >- if not in_re and next1 in "'\"`": >+ if not in_re and str(next1) in "'\"`": > in_quote = next1 > quote_buf = [] > > previous = next1 > next1 = next2 > >- if previous >= '!': >+ if str(previous) >= '!': > previous_non_space = previous > > if previous == '\\': >diff --git a/Source/JavaScriptCore/Scripts/make-js-file-arrays.py b/Source/JavaScriptCore/Scripts/make-js-file-arrays.py >index c37cc12f22d5bf9e7942afb2377eed67a8bd3f7b..8624bfe8daf6cc244b5b16a8fac71c9ee0820165 100755 >--- a/Source/JavaScriptCore/Scripts/make-js-file-arrays.py >+++ b/Source/JavaScriptCore/Scripts/make-js-file-arrays.py >@@ -25,7 +25,11 @@ from __future__ import print_function > import io > import os > from optparse import OptionParser >-from StringIO import StringIO >+import sys >+if sys.version_info.major == 2: >+ from StringIO import StringIO >+else: >+ from io import StringIO > from jsmin import JavascriptMinify > > >@@ -37,7 +41,7 @@ def stringifyCodepoint(code): > > > def chunk(list, chunkSize): >- for i in xrange(0, len(list), chunkSize): >+ for i in range(0, len(list), chunkSize): > yield list[i:i + chunkSize] > > >@@ -85,7 +89,7 @@ def main(): > print('extern const char {0:s}JavaScript[{1:d}];'.format(variableName, size), file=headerFile) > print('const char {0:s}JavaScript[{1:d}] = {{'.format(variableName, size), file=sourceFile) > >- codepoints = map(ord, characters) >+ codepoints = list(map(ord, characters)) > for codepointChunk in chunk(codepoints, 16): > print(' {0:s},'.format(','.join(map(stringifyCodepoint, codepointChunk))), file=sourceFile) > >diff --git a/Source/JavaScriptCore/Scripts/wkbuiltins/__init__.py b/Source/JavaScriptCore/Scripts/wkbuiltins/__init__.py >new file mode 100644 >index 0000000000000000000000000000000000000000..d6f9329b2b4e9755bafb62587104b26f1f34d02d >--- /dev/null >+++ b/Source/JavaScriptCore/Scripts/wkbuiltins/__init__.py >@@ -0,0 +1,3 @@ >+# Required for Python to search this directory for module files >+ >+from wkbuiltins import * >diff --git a/Source/JavaScriptCore/Scripts/wkbuiltins/builtins.py b/Source/JavaScriptCore/Scripts/wkbuiltins/builtins.py >new file mode 100644 >index 0000000000000000000000000000000000000000..a9aff2b1cff4f25350b7658dda49c0a5123e9c14 >--- /dev/null >+++ b/Source/JavaScriptCore/Scripts/wkbuiltins/builtins.py >@@ -0,0 +1,15 @@ >+# This file is used to simulate the builtins/ directory when generate-js-builtins.py >+# is run from JavaScriptCore framework's private headers directory, which is flattened. >+ >+from builtins_model import * >+from builtins_templates import * >+ >+from builtins_generator import * >+from builtins_generate_combined_header import * >+from builtins_generate_combined_implementation import * >+from builtins_generate_separate_header import * >+from builtins_generate_separate_implementation import * >+from builtins_generate_wrapper_header import * >+from builtins_generate_wrapper_implementation import * >+from builtins_generate_internals_wrapper_header import * >+from builtins_generate_internals_wrapper_implementation import * >diff --git a/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_combined_header.py b/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_combined_header.py >new file mode 100755 >index 0000000000000000000000000000000000000000..eac694803adbaac3e6bc48aa2a34cc8efacef2df >--- /dev/null >+++ b/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_combined_header.py >@@ -0,0 +1,171 @@ >+#!/usr/bin/env python >+# >+# Copyright (c) 2014-2016 Apple Inc. All rights reserved. >+# Copyright (c) 2014 University of Washington. All rights reserved. >+# >+# Redistribution and use in source and binary forms, with or without >+# modification, are permitted provided that the following conditions >+# are met: >+# 1. Redistributions of source code must retain the above copyright >+# notice, this list of conditions and the following disclaimer. >+# 2. 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. >+# >+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 logging >+import re >+import string >+from string import Template >+ >+from builtins_generator import BuiltinsGenerator >+from builtins_templates import BuiltinsGeneratorTemplates as Templates >+ >+log = logging.getLogger('global') >+ >+ >+class BuiltinsCombinedHeaderGenerator(BuiltinsGenerator): >+ def __init__(self, model): >+ BuiltinsGenerator.__init__(self, model) >+ >+ def output_filename(self): >+ return "%sBuiltins.h" % self.model().framework.setting('namespace') >+ >+ def generate_output(self): >+ args = { >+ 'namespace': self.model().framework.setting('namespace'), >+ 'macroPrefix': self.model().framework.setting('macro_prefix'), >+ } >+ >+ sections = [] >+ sections.append(self.generate_license()) >+ sections.append(Template(Templates.DoNotEditWarning).substitute(args)) >+ sections.append(Template(Templates.HeaderIncludeGuard).substitute(args)) >+ sections.append(self.generate_forward_declarations()) >+ sections.append(Template(Templates.NamespaceTop).substitute(args)) >+ for object in self.model().objects: >+ sections.append(self.generate_section_for_object(object)) >+ sections.append(self.generate_section_for_code_table_macro()) >+ sections.append(self.generate_section_for_code_name_macro()) >+ sections.append(self.generate_section_for_global_private_code_name_macro()) >+ sections.append(Template(Templates.CombinedHeaderStaticMacros).substitute(args)) >+ sections.append(Template(Templates.NamespaceBottom).substitute(args)) >+ >+ return "\n\n".join(sections) >+ >+ def generate_forward_declarations(self): >+ return """namespace JSC { >+class FunctionExecutable; >+class VM; >+ >+enum class ConstructAbility : unsigned; >+}""" >+ >+ def generate_section_for_object(self, object): >+ lines = [] >+ lines.append('/* %s */' % object.object_name) >+ lines.extend(self.generate_externs_for_object(object)) >+ lines.append("") >+ lines.extend(self.generate_macros_for_object(object)) >+ return '\n'.join(lines) >+ >+ def generate_externs_for_object(self, object): >+ lines = [] >+ >+ for function in object.functions: >+ function_args = { >+ 'codeName': BuiltinsGenerator.mangledNameForFunction(function) + 'Code', >+ } >+ >+ lines.append("""extern const char* s_%(codeName)s; >+extern const int s_%(codeName)sLength; >+extern const JSC::ConstructAbility s_%(codeName)sConstructAbility;""" % function_args) >+ >+ return lines >+ >+ def generate_macros_for_object(self, object): >+ args = { >+ 'macroPrefix': self.model().framework.setting('macro_prefix'), >+ 'objectMacro': object.object_name.replace('.', '').upper(), >+ } >+ >+ lines = [] >+ lines.append("#define %(macroPrefix)s_FOREACH_%(objectMacro)s_BUILTIN_DATA(macro) \\" % args) >+ for function in object.functions: >+ function_args = { >+ 'funcName': function.function_name, >+ 'mangledName': BuiltinsGenerator.mangledNameForFunction(function), >+ 'paramCount': len(function.parameters), >+ } >+ >+ lines.append(" macro(%(funcName)s, %(mangledName)s, %(paramCount)d) \\" % function_args) >+ return lines >+ >+ def generate_section_for_code_table_macro(self): >+ args = { >+ 'macroPrefix': self.model().framework.setting('macro_prefix'), >+ } >+ >+ lines = [] >+ lines.append("#define %(macroPrefix)s_FOREACH_BUILTIN_CODE(macro) \\" % args) >+ for function in self.model().all_functions(): >+ function_args = { >+ 'funcName': function.function_name, >+ 'overriddenName': function.overridden_name, >+ 'codeName': BuiltinsGenerator.mangledNameForFunction(function) + 'Code', >+ } >+ >+ lines.append(" macro(%(codeName)s, %(funcName)s, %(overriddenName)s, s_%(codeName)sLength) \\" % function_args) >+ return '\n'.join(lines) >+ >+ def generate_section_for_code_name_macro(self): >+ args = { >+ 'macroPrefix': self.model().framework.setting('macro_prefix'), >+ } >+ >+ internal_function_names = [function.function_name for function in self.model().all_internal_functions()] >+ if len(internal_function_names) != len(set(internal_function_names)): >+ log.error("There are several internal functions with the same name. Private identifiers may clash.") >+ >+ lines = [] >+ lines.append("#define %(macroPrefix)s_FOREACH_BUILTIN_FUNCTION_NAME(macro) \\" % args) >+ unique_names = list(set([function.function_name for function in self.model().all_functions()])) >+ unique_names.sort() >+ for function_name in unique_names: >+ function_args = { >+ 'funcName': function_name, >+ } >+ >+ lines.append(" macro(%(funcName)s) \\" % function_args) >+ return '\n'.join(lines) >+ >+ def generate_section_for_global_private_code_name_macro(self): >+ args = { >+ 'macroPrefix': self.model().framework.setting('macro_prefix'), >+ } >+ >+ lines = [] >+ lines.append("#define %(macroPrefix)s_FOREACH_BUILTIN_FUNCTION_PRIVATE_GLOBAL_NAME(macro) \\" % args) >+ functions = [function for function in self.model().all_functions() if function.is_global_private] >+ functions.sort(key=lambda x: x.function_name) >+ for function in functions: >+ function_args = { >+ 'funcName': function.function_name, >+ 'codeName': BuiltinsGenerator.mangledNameForFunction(function), >+ } >+ >+ lines.append(" macro(%(funcName)s, %(codeName)s) \\" % function_args) >+ >+ return '\n'.join(lines) >diff --git a/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_combined_implementation.py b/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_combined_implementation.py >new file mode 100644 >index 0000000000000000000000000000000000000000..7874dcad94b4a6a2fc7c418f04e69d1395c1edb0 >--- /dev/null >+++ b/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_combined_implementation.py >@@ -0,0 +1,100 @@ >+#!/usr/bin/env python >+# >+# Copyright (c) 2014, 2015 Apple Inc. All rights reserved. >+# Copyright (c) 2014 University of Washington. All rights reserved. >+# >+# Redistribution and use in source and binary forms, with or without >+# modification, are permitted provided that the following conditions >+# are met: >+# 1. Redistributions of source code must retain the above copyright >+# notice, this list of conditions and the following disclaimer. >+# 2. 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. >+# >+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 logging >+import re >+import string >+from string import Template >+ >+from builtins_generator import BuiltinsGenerator >+from builtins_model import Framework, Frameworks >+from builtins_templates import BuiltinsGeneratorTemplates as Templates >+ >+log = logging.getLogger('global') >+ >+ >+class BuiltinsCombinedImplementationGenerator(BuiltinsGenerator): >+ def __init__(self, model): >+ BuiltinsGenerator.__init__(self, model) >+ >+ def output_filename(self): >+ return "%sBuiltins.cpp" % self.model().framework.setting('namespace') >+ >+ def generate_output(self): >+ args = { >+ 'namespace': self.model().framework.setting('namespace'), >+ 'macroPrefix': self.model().framework.setting('macro_prefix'), >+ } >+ >+ sections = [] >+ sections.append(self.generate_license()) >+ sections.append(Template(Templates.DoNotEditWarning).substitute(args)) >+ sections.append(self.generate_primary_header_includes()) >+ sections.append(self.generate_secondary_header_includes()) >+ sections.append(Template(Templates.NamespaceTop).substitute(args)) >+ for function in self.model().all_functions(): >+ sections.append(self.generate_embedded_code_string_section_for_function(function)) >+ if self.model().framework is Frameworks.JavaScriptCore: >+ sections.append(Template(Templates.CombinedJSCImplementationStaticMacros).substitute(args)) >+ elif self.model().framework is Frameworks.WebCore: >+ sections.append(Template(Templates.CombinedWebCoreImplementationStaticMacros).substitute(args)) >+ sections.append(Template(Templates.NamespaceBottom).substitute(args)) >+ >+ return "\n\n".join(sections) >+ >+ def generate_secondary_header_includes(self): >+ header_includes = [ >+ (["JavaScriptCore"], >+ ("JavaScriptCore", "builtins/BuiltinExecutables.h"), >+ ), >+ (["JavaScriptCore", "WebCore"], >+ ("JavaScriptCore", "heap/HeapInlines.h"), >+ ), >+ (["JavaScriptCore", "WebCore"], >+ ("JavaScriptCore", "runtime/UnlinkedFunctionExecutable.h"), >+ ), >+ (["JavaScriptCore", "WebCore"], >+ ("JavaScriptCore", "runtime/JSCellInlines.h"), >+ ), >+ (["WebCore"], >+ ("JavaScriptCore", "runtime/StructureInlines.h"), >+ ), >+ (["WebCore"], >+ ("JavaScriptCore", "runtime/JSCJSValueInlines.h"), >+ ), >+ (["JavaScriptCore", "WebCore"], >+ ("JavaScriptCore", "runtime/VM.h"), >+ ), >+ (["JavaScriptCore", "WebCore"], >+ ("JavaScriptCore", "runtime/IdentifierInlines.h"), >+ ), >+ (["JavaScriptCore", "WebCore"], >+ ("JavaScriptCore", "runtime/Intrinsic.h"), >+ ), >+ ] >+ >+ return '\n'.join(self.generate_includes_from_entries(header_includes)) >diff --git a/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_internals_wrapper_header.py b/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_internals_wrapper_header.py >new file mode 100755 >index 0000000000000000000000000000000000000000..8025612022173e04561d0b34283dfab6958528e1 >--- /dev/null >+++ b/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_internals_wrapper_header.py >@@ -0,0 +1,113 @@ >+#!/usr/bin/env python >+# >+# Copyright (c) 2016 Apple 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: >+# 1. Redistributions of source code must retain the above copyright >+# notice, this list of conditions and the following disclaimer. >+# 2. 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. >+# >+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 logging >+from string import Template >+ >+from builtins_generator import BuiltinsGenerator, WK_lcfirst, WK_ucfirst >+from builtins_templates import BuiltinsGeneratorTemplates as Templates >+ >+log = logging.getLogger('global') >+ >+ >+class BuiltinsInternalsWrapperHeaderGenerator(BuiltinsGenerator): >+ def __init__(self, model): >+ BuiltinsGenerator.__init__(self, model) >+ self.internals = [object for object in model.objects if 'internal' in object.annotations] >+ >+ def output_filename(self): >+ return "%sJSBuiltinInternals.h" % self.model().framework.setting('namespace') >+ >+ def generate_output(self): >+ args = { >+ 'namespace': self.model().framework.setting('namespace'), >+ } >+ >+ sections = [] >+ sections.append(self.generate_license()) >+ sections.append(Template(Templates.DoNotEditWarning).substitute(args)) >+ sections.append(Template(Templates.HeaderIncludeGuard).substitute(args)) >+ sections.append(self.generate_secondary_header_includes()) >+ >+ sections.append(Template(Templates.NamespaceTop).substitute(args)) >+ sections.append(self.generate_section_for_object()) >+ sections.append(Template(Templates.NamespaceBottom).substitute(args)) >+ >+ return "\n\n".join(sections) >+ >+ def generate_secondary_header_includes(self): >+ header_includes = [ >+ (["WebCore"], ("JavaScriptCore", "heap/WeakInlines.h")), >+ (["WebCore"], ("JavaScriptCore", "runtime/VM.h")) >+ ] >+ for object in self.internals: >+ header_includes.append((["WebCore"], ("WebCore", object.object_name + "Builtins.h"))) >+ >+ return '\n'.join(self.generate_includes_from_entries(header_includes)) >+ >+ def generate_section_for_object(self): >+ lines = ["class JSDOMGlobalObject;", >+ "", >+ "class JSBuiltinInternalFunctions {", >+ "public:"] >+ >+ lines.append(" explicit JSBuiltinInternalFunctions(JSC::VM&);") >+ lines.append(self.generate_methods()) >+ lines.append(self.generate_accessors()) >+ lines.append("private:") >+ lines.append(self.generate_members()) >+ lines.append("};") >+ return '\n'.join(lines) >+ >+ def accessor_name(self, object): >+ return WK_lcfirst(object.object_name) >+ >+ def member_name(self, object): >+ return "m_" + self.accessor_name(object) >+ >+ def member_type(self, object): >+ return WK_ucfirst(object.object_name) + "BuiltinFunctions" >+ >+ def generate_methods(self): >+ return """ >+ void visit(JSC::SlotVisitor&); >+ void initialize(JSDOMGlobalObject&); >+""" >+ >+ def generate_accessors(self): >+ lines = [] >+ for object in self.internals: >+ accessor = " %s& %s() { return %s; }" % (self.member_type(object), self.accessor_name(object), self.member_name(object)) >+ lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), accessor)) >+ lines.append("") >+ return '\n'.join(lines) >+ >+ def generate_members(self): >+ lines = [" JSC::VM& m_vm;"] >+ for object in self.internals: >+ member = " %s %s;" % (self.member_type(object), self.member_name(object)) >+ lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), member)) >+ return '\n'.join(lines) >diff --git a/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_internals_wrapper_implementation.py b/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_internals_wrapper_implementation.py >new file mode 100755 >index 0000000000000000000000000000000000000000..39825067a5424f66969e566fd5fcda4a5931f7df >--- /dev/null >+++ b/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_internals_wrapper_implementation.py >@@ -0,0 +1,156 @@ >+#!/usr/bin/env python >+# >+# Copyright (c) 2016 Apple 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: >+# 1. Redistributions of source code must retain the above copyright >+# notice, this list of conditions and the following disclaimer. >+# 2. 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. >+# >+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 logging >+from string import Template >+ >+from builtins_generator import BuiltinsGenerator, WK_lcfirst, WK_ucfirst >+from builtins_templates import BuiltinsGeneratorTemplates as Templates >+ >+log = logging.getLogger('global') >+ >+ >+class BuiltinsInternalsWrapperImplementationGenerator(BuiltinsGenerator): >+ def __init__(self, model): >+ BuiltinsGenerator.__init__(self, model) >+ self.internals = [object for object in model.objects if 'internal' in object.annotations] >+ >+ def output_filename(self): >+ return "%sJSBuiltinInternals.cpp" % self.model().framework.setting('namespace') >+ >+ def generate_output(self): >+ args = { >+ 'namespace': self.model().framework.setting('namespace'), >+ } >+ >+ sections = [] >+ sections.append(self.generate_license()) >+ sections.append(Template(Templates.DoNotEditWarning).substitute(args)) >+ sections.append(self.generate_primary_header_includes()) >+ sections.append(self.generate_secondary_header_includes()) >+ >+ sections.append(Template(Templates.NamespaceTop).substitute(args)) >+ sections.append(self.generate_section_for_object()) >+ sections.append(Template(Templates.NamespaceBottom).substitute(args)) >+ >+ return "\n\n".join(sections) >+ >+ def generate_secondary_header_includes(self): >+ header_includes = [ >+ (["WebCore"], >+ ("WebCore", "JSDOMGlobalObject.h"), >+ ), >+ (["WebCore"], >+ ("WebCore", "WebCoreJSClientData.h"), >+ ), >+ (["WebCore"], >+ ("JavaScriptCore", "heap/HeapInlines.h"), >+ ), >+ (["WebCore"], >+ ("JavaScriptCore", "heap/SlotVisitorInlines.h"), >+ ), >+ (["WebCore"], >+ ("JavaScriptCore", "runtime/JSCJSValueInlines.h"), >+ ), >+ (["WebCore"], >+ ("JavaScriptCore", "runtime/StructureInlines.h"), >+ ), >+ ] >+ return '\n'.join(self.generate_includes_from_entries(header_includes)) >+ >+ def generate_section_for_object(self): >+ lines = [] >+ >+ lines.append(self.generate_constructor()) >+ lines.append(self.generate_visit_method()) >+ lines.append(self.generate_initialize_method()) >+ return '\n'.join(lines) >+ >+ def accessor_name(self, object): >+ return WK_lcfirst(object.object_name) >+ >+ def member_name(self, object): >+ return "m_" + self.accessor_name(object) >+ >+ def member_type(self, object): >+ return WK_ucfirst(object.object_name) + "BuiltinFunctions" >+ >+ def generate_constructor(self): >+ guards = set([object.annotations.get('conditional') for object in self.internals if 'conditional' in object.annotations]) >+ lines = ["JSBuiltinInternalFunctions::JSBuiltinInternalFunctions(JSC::VM& vm)", >+ " : m_vm(vm)"] >+ for object in self.internals: >+ initializer = " , %s(m_vm)" % self.member_name(object) >+ lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), initializer)) >+ lines.append("{") >+ lines.append(" UNUSED_PARAM(vm);") >+ lines.append("}\n") >+ return '\n'.join(lines) >+ >+ def property_macro(self, object): >+ lines = [] >+ lines.append("#define DECLARE_GLOBAL_STATIC(name) \\") >+ lines.append(" JSDOMGlobalObject::GlobalPropertyInfo( \\") >+ lines.append(" clientData.builtinFunctions().%sBuiltins().name##PrivateName(), %s().m_##name##Function.get() , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)," % (self.accessor_name(object), self.accessor_name(object))) >+ lines.append(" WEBCORE_FOREACH_%s_BUILTIN_FUNCTION_NAME(DECLARE_GLOBAL_STATIC)" % object.object_name.upper()) >+ lines.append("#undef DECLARE_GLOBAL_STATIC") >+ return '\n'.join(lines) >+ >+ def generate_visit_method(self): >+ lines = ["void JSBuiltinInternalFunctions::visit(JSC::SlotVisitor& visitor)", >+ "{"] >+ for object in self.internals: >+ visit = " %s.visit(visitor);" % self.member_name(object) >+ lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), visit)) >+ lines.append(" UNUSED_PARAM(visitor);") >+ lines.append("}\n") >+ return '\n'.join(lines) >+ >+ def _generate_initialize_static_globals(self): >+ lines = [" JSVMClientData& clientData = *static_cast<JSVMClientData*>(m_vm.clientData);", >+ " JSDOMGlobalObject::GlobalPropertyInfo staticGlobals[] = {"] >+ for object in self.internals: >+ lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), self.property_macro(object))) >+ lines.append(" };") >+ lines.append(" globalObject.addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals));") >+ lines.append(" UNUSED_PARAM(clientData);") >+ return '\n'.join(lines) >+ >+ def generate_initialize_method(self): >+ lines = ["void JSBuiltinInternalFunctions::initialize(JSDOMGlobalObject& globalObject)", >+ "{", >+ " UNUSED_PARAM(globalObject);"] >+ >+ for object in self.internals: >+ init = " %s.init(globalObject);" % self.member_name(object) >+ lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), init)) >+ lines.append("") >+ >+ guards = set([object.annotations.get('conditional') for object in self.internals if 'conditional' in object.annotations]) >+ lines.append(BuiltinsGenerator.wrap_with_guard(" || ".join(guards), self._generate_initialize_static_globals())) >+ >+ lines.append("}") >+ return '\n'.join(lines) >diff --git a/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_separate_header.py b/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_separate_header.py >new file mode 100755 >index 0000000000000000000000000000000000000000..58c8f2ac8a6415a291cff888cf1f680c1d66047d >--- /dev/null >+++ b/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_separate_header.py >@@ -0,0 +1,198 @@ >+#!/usr/bin/env python >+# >+# Copyright (c) 2014, 2015 Apple Inc. All rights reserved. >+# Copyright (c) 2014 University of Washington. All rights reserved. >+# >+# Redistribution and use in source and binary forms, with or without >+# modification, are permitted provided that the following conditions >+# are met: >+# 1. Redistributions of source code must retain the above copyright >+# notice, this list of conditions and the following disclaimer. >+# 2. 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. >+# >+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 logging >+import re >+import string >+from string import Template >+ >+from builtins_generator import BuiltinsGenerator >+from builtins_model import Frameworks >+from builtins_templates import BuiltinsGeneratorTemplates as Templates >+ >+log = logging.getLogger('global') >+ >+ >+class BuiltinsSeparateHeaderGenerator(BuiltinsGenerator): >+ def __init__(self, model, object): >+ BuiltinsGenerator.__init__(self, model) >+ self.object = object >+ >+ def output_filename(self): >+ return "%sBuiltins.h" % BuiltinsGenerator.mangledNameForObject(self.object) >+ >+ def macro_prefix(self): >+ return self.model().framework.setting('macro_prefix') >+ >+ def generate_output(self): >+ args = { >+ 'namespace': self.model().framework.setting('namespace'), >+ 'macroPrefix': self.macro_prefix(), >+ 'objectName': self.object.object_name, >+ 'objectMacro': self.object.object_name.upper(), >+ } >+ >+ conditional_guard = self.object.annotations.get('conditional') >+ >+ sections = [] >+ sections.append(self.generate_license()) >+ sections.append(Template(Templates.DoNotEditWarning).substitute(args)) >+ sections.append(Template(Templates.HeaderIncludeGuard).substitute(args)) >+ if conditional_guard is not None: >+ sections.append("#if %s" % conditional_guard) >+ sections.append(self.generate_secondary_header_includes()) >+ sections.append(self.generate_forward_declarations()) >+ sections.append(Template(Templates.NamespaceTop).substitute(args)) >+ sections.append(self.generate_section_for_object(self.object)) >+ sections.append(self.generate_section_for_code_table_macro()) >+ sections.append(self.generate_section_for_code_name_macro()) >+ sections.append(Template(Templates.SeparateHeaderStaticMacros).substitute(args)) >+ if self.model().framework is Frameworks.WebCore: >+ sections.append(Template(Templates.SeparateHeaderWrapperBoilerplate).substitute(args)) >+ if self.object.annotations.get('internal'): >+ sections.append(Template(Templates.SeparateHeaderInternalFunctionsBoilerplate).substitute(args)) >+ sections.append(Template(Templates.NamespaceBottom).substitute(args)) >+ if conditional_guard is not None: >+ sections.append("#endif // %s" % conditional_guard) >+ >+ return "\n\n".join(sections) >+ >+ def generate_forward_declarations(self): >+ return """namespace JSC { >+class FunctionExecutable; >+}""" >+ >+ def generate_secondary_header_includes(self): >+ header_includes = [ >+ (["WebCore"], >+ ("JavaScriptCore", "bytecode/UnlinkedFunctionExecutable.h"), >+ ), >+ >+ (["WebCore"], >+ ("JavaScriptCore", "builtins/BuiltinUtils.h"), >+ ), >+ >+ (["WebCore"], >+ ("JavaScriptCore", "runtime/Identifier.h"), >+ ), >+ >+ (["WebCore"], >+ ("JavaScriptCore", "runtime/JSFunction.h"), >+ ), >+ ] >+ >+ return '\n'.join(self.generate_includes_from_entries(header_includes)) >+ >+ def generate_section_for_object(self, object): >+ lines = [] >+ lines.append('/* %s */' % object.object_name) >+ lines.extend(self.generate_externs_for_object(object)) >+ lines.append("") >+ lines.extend(self.generate_macros_for_object(object)) >+ lines.append("") >+ lines.extend(self.generate_defines_for_object(object)) >+ return '\n'.join(lines) >+ >+ def generate_externs_for_object(self, object): >+ lines = [] >+ >+ for function in object.functions: >+ function_args = { >+ 'codeName': BuiltinsGenerator.mangledNameForFunction(function) + 'Code', >+ } >+ >+ lines.append("""extern const char* s_%(codeName)s; >+extern const int s_%(codeName)sLength; >+extern const JSC::ConstructAbility s_%(codeName)sConstructAbility;""" % function_args) >+ >+ return lines >+ >+ def generate_macros_for_object(self, object): >+ args = { >+ 'macroPrefix': self.macro_prefix(), >+ 'objectMacro': object.object_name.replace('.', '_').upper(), >+ } >+ >+ lines = [] >+ lines.append("#define %(macroPrefix)s_FOREACH_%(objectMacro)s_BUILTIN_DATA(macro) \\" % args) >+ for function in object.functions: >+ function_args = { >+ 'funcName': function.function_name, >+ 'mangledName': BuiltinsGenerator.mangledNameForFunction(function), >+ 'paramCount': len(function.parameters), >+ } >+ >+ lines.append(" macro(%(funcName)s, %(mangledName)s, %(paramCount)d) \\" % function_args) >+ return lines >+ >+ def generate_defines_for_object(self, object): >+ lines = [] >+ for function in object.functions: >+ args = { >+ 'macroPrefix': self.macro_prefix(), >+ 'objectMacro': object.object_name.replace('.', '_').upper(), >+ 'functionMacro': function.function_name.upper(), >+ } >+ lines.append("#define %(macroPrefix)s_BUILTIN_%(objectMacro)s_%(functionMacro)s 1" % args) >+ >+ return lines >+ >+ def generate_section_for_code_table_macro(self): >+ args = { >+ 'macroPrefix': self.model().framework.setting('macro_prefix'), >+ 'objectMacro': self.object.object_name.upper(), >+ } >+ >+ lines = [] >+ lines.append("#define %(macroPrefix)s_FOREACH_%(objectMacro)s_BUILTIN_CODE(macro) \\" % args) >+ for function in self.object.functions: >+ function_args = { >+ 'funcName': function.function_name, >+ 'overriddenName': function.overridden_name, >+ 'codeName': BuiltinsGenerator.mangledNameForFunction(function) + 'Code', >+ } >+ >+ lines.append(" macro(%(codeName)s, %(funcName)s, %(overriddenName)s, s_%(codeName)sLength) \\" % function_args) >+ return '\n'.join(lines) >+ >+ def generate_section_for_code_name_macro(self): >+ args = { >+ 'macroPrefix': self.macro_prefix(), >+ 'objectMacro': self.object.object_name.upper(), >+ } >+ >+ lines = [] >+ lines.append("#define %(macroPrefix)s_FOREACH_%(objectMacro)s_BUILTIN_FUNCTION_NAME(macro) \\" % args) >+ unique_names = list(set([function.function_name for function in self.object.functions])) >+ unique_names.sort() >+ for function_name in unique_names: >+ function_args = { >+ 'funcName': function_name, >+ } >+ >+ lines.append(" macro(%(funcName)s) \\" % function_args) >+ return '\n'.join(lines) >diff --git a/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_separate_implementation.py b/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_separate_implementation.py >new file mode 100644 >index 0000000000000000000000000000000000000000..ced9a53867d42bc88562d208b4724cf6f6684900 >--- /dev/null >+++ b/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_separate_implementation.py >@@ -0,0 +1,112 @@ >+#!/usr/bin/env python >+# >+# Copyright (c) 2014, 2015 Apple Inc. All rights reserved. >+# Copyright (c) 2014 University of Washington. All rights reserved. >+# >+# Redistribution and use in source and binary forms, with or without >+# modification, are permitted provided that the following conditions >+# are met: >+# 1. Redistributions of source code must retain the above copyright >+# notice, this list of conditions and the following disclaimer. >+# 2. 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. >+# >+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 logging >+import re >+import string >+from string import Template >+ >+from builtins_generator import BuiltinsGenerator, WK_lcfirst >+from builtins_model import Framework, Frameworks >+from builtins_templates import BuiltinsGeneratorTemplates as Templates >+ >+log = logging.getLogger('global') >+ >+ >+class BuiltinsSeparateImplementationGenerator(BuiltinsGenerator): >+ def __init__(self, model, object): >+ BuiltinsGenerator.__init__(self, model) >+ self.object = object >+ >+ def output_filename(self): >+ return "%sBuiltins.cpp" % BuiltinsGenerator.mangledNameForObject(self.object) >+ >+ def macro_prefix(self): >+ return self.model().framework.setting('macro_prefix') >+ >+ def generate_output(self): >+ args = { >+ 'namespace': self.model().framework.setting('namespace'), >+ 'macroPrefix': self.macro_prefix(), >+ 'objectMacro': self.object.object_name.upper(), >+ 'objectNameLC': WK_lcfirst(self.object.object_name), >+ } >+ >+ conditional_guard = self.object.annotations.get('conditional') >+ >+ sections = [] >+ sections.append(self.generate_license()) >+ sections.append(Template(Templates.DoNotEditWarning).substitute(args)) >+ sections.append(self.generate_primary_header_includes()) >+ if conditional_guard is not None: >+ sections.append("#if %s" % conditional_guard) >+ sections.append(self.generate_secondary_header_includes()) >+ sections.append(Template(Templates.NamespaceTop).substitute(args)) >+ for function in self.object.functions: >+ sections.append(self.generate_embedded_code_string_section_for_function(function)) >+ if self.model().framework is Frameworks.JavaScriptCore: >+ sections.append(Template(Templates.SeparateJSCImplementationStaticMacros).substitute(args)) >+ elif self.model().framework is Frameworks.WebCore: >+ sections.append(Template(Templates.SeparateWebCoreImplementationStaticMacros).substitute(args)) >+ sections.append(Template(Templates.NamespaceBottom).substitute(args)) >+ if conditional_guard is not None: >+ sections.append("#endif // %s\n" % conditional_guard) >+ >+ return "\n\n".join(sections) >+ >+ def generate_secondary_header_includes(self): >+ header_includes = [ >+ (["JavaScriptCore"], >+ ("JavaScriptCore", "builtins/BuiltinExecutables.h"), >+ ), >+ (["JavaScriptCore", "WebCore"], >+ ("JavaScriptCore", "heap/HeapInlines.h"), >+ ), >+ (["JavaScriptCore", "WebCore"], >+ ("JavaScriptCore", "runtime/JSCellInlines.h"), >+ ), >+ (["WebCore"], >+ ("JavaScriptCore", "runtime/StructureInlines.h"), >+ ), >+ (["WebCore"], >+ ("JavaScriptCore", "runtime/JSCJSValueInlines.h"), >+ ), >+ (["JavaScriptCore", "WebCore"], >+ ("JavaScriptCore", "runtime/VM.h"), >+ ), >+ (["WebCore"], >+ ("WebCore", "bindings/js/WebCoreJSClientData.h"), >+ ), >+ (["JavaScriptCore", "WebCore"], >+ ("JavaScriptCore", "runtime/IdentifierInlines.h"), >+ ), >+ (["JavaScriptCore", "WebCore"], >+ ("JavaScriptCore", "runtime/Intrinsic.h"), >+ ), >+ ] >+ >+ return '\n'.join(self.generate_includes_from_entries(header_includes)) >diff --git a/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_wrapper_header.py b/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_wrapper_header.py >new file mode 100755 >index 0000000000000000000000000000000000000000..04abe567803708019699b2ac4c880522fdd85469 >--- /dev/null >+++ b/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_wrapper_header.py >@@ -0,0 +1,119 @@ >+#!/usr/bin/env python >+# >+# Copyright (c) 2016 Apple 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: >+# 1. Redistributions of source code must retain the above copyright >+# notice, this list of conditions and the following disclaimer. >+# 2. 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. >+# >+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 logging >+from string import Template >+ >+from builtins_generator import BuiltinsGenerator, WK_lcfirst, WK_ucfirst >+from builtins_templates import BuiltinsGeneratorTemplates as Templates >+ >+log = logging.getLogger('global') >+ >+ >+class BuiltinsWrapperHeaderGenerator(BuiltinsGenerator): >+ def __init__(self, model): >+ BuiltinsGenerator.__init__(self, model) >+ >+ def output_filename(self): >+ return "%sJSBuiltins.h" % self.model().framework.setting('namespace') >+ >+ def generate_output(self): >+ args = { >+ 'namespace': self.model().framework.setting('namespace'), >+ } >+ >+ sections = [] >+ sections.append(self.generate_license()) >+ sections.append(Template(Templates.DoNotEditWarning).substitute(args)) >+ sections.append(Template(Templates.HeaderIncludeGuard).substitute(args)) >+ sections.append(self.generate_secondary_header_includes()) >+ >+ sections.append(Template(Templates.NamespaceTop).substitute(args)) >+ sections.append(self.generate_section_for_object()) >+ sections.append(Template(Templates.NamespaceBottom).substitute(args)) >+ >+ return "\n\n".join(sections) >+ >+ def generate_secondary_header_includes(self): >+ header_includes = [ >+ (["WebCore"], >+ ("JavaScriptCore", "runtime/VM.h"), >+ ), >+ ] >+ for object in self.model().objects: >+ header_includes.append((["WebCore"], ("WebCore", object.object_name + "Builtins.h"))) >+ >+ return '\n'.join(self.generate_includes_from_entries(header_includes)) >+ >+ def generate_section_for_object(self): >+ lines = ["class JSBuiltinFunctions {", >+ "public:"] >+ >+ lines.append(self.generate_constructor()) >+ lines.append(self.generate_accessors()) >+ lines.append("private:") >+ lines.append(self.generate_members()) >+ lines.append("};") >+ return '\n'.join(lines) >+ >+ def accessor_name(self, object): >+ return WK_lcfirst(object.object_name) + "Builtins" >+ >+ def member_name(self, object): >+ return "m_" + self.accessor_name(object) >+ >+ def member_type(self, object): >+ return WK_ucfirst(object.object_name) + "BuiltinsWrapper" >+ >+ def generate_constructor(self): >+ lines = [" explicit JSBuiltinFunctions(JSC::VM& vm)", >+ " : m_vm(vm)"] >+ for object in self.model().objects: >+ member_init = " , %s(&m_vm)" % self.member_name(object) >+ lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), member_init)) >+ lines.append(" {") >+ for object in self.model().objects: >+ if not 'internal' in object.annotations: >+ continue >+ internal_export_names = " %s.exportNames();" % self.member_name(object) >+ lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), internal_export_names)) >+ lines.append(" }\n") >+ return '\n'.join(lines) >+ >+ def generate_accessors(self): >+ lines = [] >+ for object in self.model().objects: >+ accessor = " %s& %s() { return %s; }" % (self.member_type(object), self.accessor_name(object), self.member_name(object)) >+ lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), accessor)) >+ lines.append("") >+ return '\n'.join(lines) >+ >+ def generate_members(self): >+ lines = [" JSC::VM& m_vm;"] >+ for object in self.model().objects: >+ member = " %s %s;" % (self.member_type(object), self.member_name(object)) >+ lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), member)) >+ return '\n'.join(lines) >diff --git a/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_wrapper_implementation.py b/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_wrapper_implementation.py >new file mode 100755 >index 0000000000000000000000000000000000000000..0055917fdc82d3c6c675916b04ec0f6147c38ee8 >--- /dev/null >+++ b/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_wrapper_implementation.py >@@ -0,0 +1,61 @@ >+#!/usr/bin/env python >+# >+# Copyright (c) 2016 Apple 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: >+# 1. Redistributions of source code must retain the above copyright >+# notice, this list of conditions and the following disclaimer. >+# 2. 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. >+# >+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 logging >+from string import Template >+ >+from builtins_generator import BuiltinsGenerator >+from builtins_templates import BuiltinsGeneratorTemplates as Templates >+ >+log = logging.getLogger('global') >+ >+ >+class BuiltinsWrapperImplementationGenerator(BuiltinsGenerator): >+ def __init__(self, model): >+ BuiltinsGenerator.__init__(self, model) >+ >+ def output_filename(self): >+ return "%sJSBuiltins.cpp" % self.model().framework.setting('namespace') >+ >+ def generate_output(self): >+ args = { >+ 'namespace': self.model().framework.setting('namespace'), >+ } >+ >+ sections = [] >+ sections.append(self.generate_license()) >+ sections.append(Template(Templates.DoNotEditWarning).substitute(args)) >+ >+ sections.append(self.generate_section_for_object()) >+ >+ return "\n\n".join(sections) >+ >+ def generate_section_for_object(self): >+ header_includes = [] >+ for object in self.model().objects: >+ header_includes.append((["WebCore"], ("WebCore", object.object_name + "Builtins.cpp"))) >+ >+ return '\n'.join(self.generate_includes_from_entries(header_includes)) >diff --git a/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generator.py b/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generator.py >new file mode 100644 >index 0000000000000000000000000000000000000000..7fc7a1041b303f43b392876ebfd10bb82c6b69ac >--- /dev/null >+++ b/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generator.py >@@ -0,0 +1,182 @@ >+#!/usr/bin/env python >+# >+# Copyright (c) 2014, 2015 Apple Inc. All rights reserved. >+# Copyright (c) 2014 University of Washington. All rights reserved. >+# >+# Redistribution and use in source and binary forms, with or without >+# modification, are permitted provided that the following conditions >+# are met: >+# 1. Redistributions of source code must retain the above copyright >+# notice, this list of conditions and the following disclaimer. >+# 2. 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. >+# >+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 logging >+import os.path >+import re >+from string import Template >+import json >+ >+from builtins_model import BuiltinFunction, BuiltinObject >+from builtins_templates import BuiltinsGeneratorTemplates as Templates >+ >+log = logging.getLogger('global') >+ >+ >+# These match WK_lcfirst and WK_ucfirst defined in CodeGenerator.pm. >+def WK_lcfirst(str): >+ str = str[:1].lower() + str[1:] >+ str = str.replace('dOM', 'dom') >+ str = str.replace('uRL', 'url') >+ str = str.replace('jS', 'js') >+ str = str.replace('xML', 'xml') >+ str = str.replace('xSLT', 'xslt') >+ str = str.replace('cSS', 'css') >+ str = str.replace('rTC', 'rtc') >+ return str >+ >+ >+def WK_ucfirst(str): >+ str = str[:1].upper() + str[1:] >+ str = str.replace('Xml', 'XML') >+ str = str.replace('Svg', 'SVG') >+ return str >+ >+ >+class BuiltinsGenerator: >+ def __init__(self, model): >+ self._model = model >+ >+ def model(self): >+ return self._model >+ >+ # These methods are overridden by subclasses. >+ >+ def generate_output(self): >+ pass >+ >+ def output_filename(self): >+ pass >+ >+ # Shared code generation methods. >+ def generate_license(self): >+ raw_license = Template(Templates.LicenseText).substitute(None) >+ copyrights = self._model.copyrights() >+ copyrights.sort() >+ >+ license_block = [] >+ license_block.append("/*") >+ for copyright in copyrights: >+ license_block.append(" * Copyright (c) %s" % copyright) >+ if len(copyrights) > 0: >+ license_block.append(" * ") >+ >+ for line in raw_license.split('\n'): >+ license_block.append(" * " + line) >+ >+ license_block.append(" */") >+ >+ return '\n'.join(license_block) >+ >+ def generate_includes_from_entries(self, entries): >+ includes = set() >+ for entry in entries: >+ (allowed_framework_names, data) = entry >+ (framework_name, header_path) = data >+ >+ if self.model().framework.name not in allowed_framework_names: >+ continue >+ if self.model().framework.name != framework_name: >+ includes.add("#include <%s/%s>" % (framework_name, os.path.basename(header_path))) >+ else: >+ includes.add("#include \"%s\"" % os.path.basename(header_path)) >+ >+ return sorted(list(includes)) >+ >+ def generate_primary_header_includes(self): >+ name, _ = os.path.splitext(self.output_filename()) >+ return '\n'.join([ >+ "#include \"config.h\"", >+ "#include \"%s.h\"" % name, >+ ]) >+ >+ def generate_embedded_code_string_section_for_function(self, function): >+ text = function.function_source >+ # Wrap it in parens to avoid adding to global scope. >+ text = "(function " + text[text.index("("):] + ")" >+ embeddedSourceLength = len(text) + 1 # For extra \n. >+ # Lazy way to escape quotes, I think? >+ textLines = json.dumps(text)[1:-1].split("\\n") >+ # This looks scary because we need the JS source itself to have newlines. >+ embeddedSource = '\n'.join([' "%s\\n" \\' % line for line in textLines]) >+ >+ constructAbility = "CannotConstruct" >+ if function.is_constructor: >+ constructAbility = "CanConstruct" >+ >+ args = { >+ 'codeName': BuiltinsGenerator.mangledNameForFunction(function) + 'Code', >+ 'embeddedSource': embeddedSource, >+ 'embeddedSourceLength': embeddedSourceLength, >+ 'canConstruct': constructAbility, >+ 'intrinsic': function.intrinsic >+ } >+ >+ lines = [] >+ lines.append("const JSC::ConstructAbility s_%(codeName)sConstructAbility = JSC::ConstructAbility::%(canConstruct)s;" % args) >+ lines.append("const int s_%(codeName)sLength = %(embeddedSourceLength)d;" % args) >+ lines.append("static const JSC::Intrinsic s_%(codeName)sIntrinsic = JSC::%(intrinsic)s;" % args) >+ lines.append("const char* s_%(codeName)s =\n%(embeddedSource)s\n;" % args) >+ return '\n'.join(lines) >+ >+ # Helper methods. >+ >+ @staticmethod >+ def wrap_with_guard(guard, text): >+ if not guard: >+ return text >+ return '\n'.join([ >+ '#if %s' % guard, >+ text, >+ '#endif // %s' % guard, >+ ]) >+ >+ @staticmethod >+ def mangledNameForObject(object): >+ if not isinstance(object, BuiltinObject): >+ raise Exception("Invalid argument passed to mangledNameForObject()") >+ >+ def toCamel(match): >+ str = match.group(0) >+ return str[1].upper() >+ return re.sub(r'\.[a-z]', toCamel, object.object_name, flags=re.IGNORECASE) >+ >+ @staticmethod >+ def mangledNameForFunction(function): >+ if not isinstance(function, BuiltinFunction): >+ raise Exception("Invalid argument passed to mangledNameForFunction()") >+ >+ function_name = WK_ucfirst(function.function_name) >+ >+ def toCamel(match): >+ str = match.group(0) >+ return str[1].upper() >+ function_name = re.sub(r'\.[a-z]', toCamel, function_name, flags=re.IGNORECASE) >+ if function.is_constructor: >+ function_name = function_name + "Constructor" >+ >+ object_name = BuiltinsGenerator.mangledNameForObject(function.object) >+ return WK_lcfirst(object_name + function_name) >diff --git a/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_model.py b/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_model.py >new file mode 100755 >index 0000000000000000000000000000000000000000..df4da75d174e47023ffa04e2f7690dde12e22f23 >--- /dev/null >+++ b/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_model.py >@@ -0,0 +1,311 @@ >+#!/usr/bin/env python >+# >+# Copyright (c) 2015-2016 Apple 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: >+# 1. Redistributions of source code must retain the above copyright >+# notice, this list of conditions and the following disclaimer. >+# 2. 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. >+# >+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 logging >+import re >+import os >+import sys >+ >+from builtins_templates import BuiltinsGeneratorTemplates as Templates >+ >+log = logging.getLogger('global') >+ >+_FRAMEWORK_CONFIG_MAP = { >+ "JavaScriptCore": { >+ "macro_prefix": "JSC", >+ "namespace": "JSC", >+ }, >+ "WebCore": { >+ "macro_prefix": "WEBCORE", >+ "namespace": "WebCore", >+ }, >+} >+ >+functionHeadRegExp = re.compile(r"(?:@[\w|=\[\] \"\.]+\s*\n)*function\s+\w+\s*\(.*?\)", re.MULTILINE | re.DOTALL) >+functionGlobalPrivateRegExp = re.compile(r".*^@globalPrivate", re.MULTILINE | re.DOTALL) >+functionIntrinsicRegExp = re.compile(r".*^@intrinsic=(\w+)", re.MULTILINE | re.DOTALL) >+functionIsConstructorRegExp = re.compile(r".*^@constructor", re.MULTILINE | re.DOTALL) >+functionIsGetterRegExp = re.compile(r".*^@getter", re.MULTILINE | re.DOTALL) >+functionNameRegExp = re.compile(r"function\s+(\w+)\s*\(", re.MULTILINE | re.DOTALL) >+functionOverriddenNameRegExp = re.compile(r".*^@overriddenName=(\".+\")$", re.MULTILINE | re.DOTALL) >+functionParameterFinder = re.compile(r"^function\s+(?:\w+)\s*\(((?:\s*\w+)?\s*(?:\s*,\s*\w+)*)?\s*\)", re.MULTILINE | re.DOTALL) >+ >+multilineCommentRegExp = re.compile(r"\/\*.*?\*\/", re.MULTILINE | re.DOTALL) >+singleLineCommentRegExp = re.compile(r"\/\/.*?\n", re.MULTILINE | re.DOTALL) >+keyValueAnnotationCommentRegExp = re.compile(r"^\/\/ @(\w+)=([^=]+?)\n", re.MULTILINE | re.DOTALL) >+flagAnnotationCommentRegExp = re.compile(r"^\/\/ @(\w+)[^=]*?\n", re.MULTILINE | re.DOTALL) >+lineWithOnlySingleLineCommentRegExp = re.compile(r"^\s*\/\/\n", re.MULTILINE | re.DOTALL) >+lineWithTrailingSingleLineCommentRegExp = re.compile(r"\s*\/\/\n", re.MULTILINE | re.DOTALL) >+leadingWhitespaceRegExp = re.compile(r"^ +", re.MULTILINE | re.DOTALL) >+multipleEmptyLinesRegExp = re.compile(r"\n{2,}", re.MULTILINE | re.DOTALL) >+ >+ >+class ParseException(Exception): >+ pass >+ >+ >+class Framework: >+ def __init__(self, name): >+ self._settings = _FRAMEWORK_CONFIG_MAP[name] >+ self.name = name >+ >+ def setting(self, key, default=''): >+ return self._settings.get(key, default) >+ >+ @staticmethod >+ def fromString(frameworkString): >+ if frameworkString == "JavaScriptCore": >+ return Frameworks.JavaScriptCore >+ >+ if frameworkString == "WebCore": >+ return Frameworks.WebCore >+ >+ raise ParseException("Unknown framework: %s" % frameworkString) >+ >+ >+class Frameworks: >+ JavaScriptCore = Framework("JavaScriptCore") >+ WebCore = Framework("WebCore") >+ >+ >+class BuiltinObject: >+ def __init__(self, object_name, annotations, functions): >+ self.object_name = object_name >+ self.annotations = annotations >+ self.functions = functions >+ self.collection = None # Set by the owning BuiltinsCollection >+ >+ for function in self.functions: >+ function.object = self >+ >+ >+class BuiltinFunction: >+ def __init__(self, function_name, function_source, parameters, is_constructor, is_global_private, intrinsic, overridden_name): >+ self.function_name = function_name >+ self.function_source = function_source >+ self.parameters = parameters >+ self.is_constructor = is_constructor >+ self.is_global_private = is_global_private >+ self.intrinsic = intrinsic >+ self.overridden_name = overridden_name >+ self.object = None # Set by the owning BuiltinObject >+ >+ @staticmethod >+ def fromString(function_string): >+ function_source = multilineCommentRegExp.sub("", function_string) >+ >+ intrinsic = "NoIntrinsic" >+ intrinsicMatch = functionIntrinsicRegExp.search(function_source) >+ if intrinsicMatch: >+ intrinsic = intrinsicMatch.group(1) >+ function_source = functionIntrinsicRegExp.sub("", function_source) >+ >+ overridden_name = None >+ overriddenNameMatch = functionOverriddenNameRegExp.search(function_source) >+ if overriddenNameMatch: >+ overridden_name = overriddenNameMatch.group(1) >+ function_source = functionOverriddenNameRegExp.sub("", function_source) >+ >+ if not os.getenv("CONFIGURATION", "Debug").startswith("Debug"): >+ function_source = lineWithOnlySingleLineCommentRegExp.sub("", function_source) >+ function_source = lineWithTrailingSingleLineCommentRegExp.sub("\n", function_source) >+ function_source = leadingWhitespaceRegExp.sub("", function_source) >+ function_source = multipleEmptyLinesRegExp.sub("\n", function_source) >+ >+ function_name = functionNameRegExp.findall(function_source)[0] >+ is_constructor = functionIsConstructorRegExp.match(function_source) != None >+ is_getter = functionIsGetterRegExp.match(function_source) != None >+ is_global_private = functionGlobalPrivateRegExp.match(function_source) != None >+ parameters = [s.strip() for s in functionParameterFinder.findall(function_source)[0].split(',')] >+ if len(parameters[0]) == 0: >+ parameters = [] >+ >+ if is_getter and not overridden_name: >+ overridden_name = "\"get %s\"" % (function_name) >+ >+ if not overridden_name: >+ overridden_name = "static_cast<const char*>(nullptr)" >+ >+ return BuiltinFunction(function_name, function_source, parameters, is_constructor, is_global_private, intrinsic, overridden_name) >+ >+ def __str__(self): >+ interface = "%s(%s)" % (self.function_name, ', '.join(self.parameters)) >+ if self.is_constructor: >+ interface = interface + " [Constructor]" >+ >+ return interface >+ >+ def __lt__(self, other): >+ return self.function_name < other.function_name >+ >+ >+class BuiltinsCollection: >+ def __init__(self, framework_name): >+ self._copyright_lines = set() >+ self.objects = [] >+ self.framework = Framework.fromString(framework_name) >+ log.debug("Created new Builtins collection.") >+ >+ def parse_builtins_file(self, filename, text): >+ log.debug("Parsing builtins file: %s" % filename) >+ >+ parsed_copyrights = set(self._parse_copyright_lines(text)) >+ self._copyright_lines = self._copyright_lines.union(parsed_copyrights) >+ >+ log.debug("Found copyright lines:") >+ for line in self._copyright_lines: >+ log.debug(line) >+ log.debug("") >+ >+ object_annotations = self._parse_annotations(text) >+ >+ object_name, ext = os.path.splitext(os.path.basename(filename)) >+ log.debug("Parsing object: %s" % object_name) >+ >+ parsed_functions = self._parse_functions(text) >+ for function in parsed_functions: >+ function.object = object_name >+ >+ log.debug("Parsed functions:") >+ for func in parsed_functions: >+ log.debug(func) >+ log.debug("") >+ >+ new_object = BuiltinObject(object_name, object_annotations, parsed_functions) >+ new_object.collection = self >+ self.objects.append(new_object) >+ >+ def copyrights(self): >+ owner_to_years = dict() >+ copyrightYearRegExp = re.compile(r"(\d{4})[, ]{0,2}") >+ ownerStartRegExp = re.compile(r"[^\d, ]") >+ >+ # Returns deduplicated copyrights keyed on the owner. >+ for line in self._copyright_lines: >+ years = set(copyrightYearRegExp.findall(line)) >+ ownerIndex = ownerStartRegExp.search(line).start() >+ owner = line[ownerIndex:] >+ log.debug("Found years: %s and owner: %s" % (years, owner)) >+ if owner not in owner_to_years: >+ owner_to_years[owner] = set() >+ >+ owner_to_years[owner] = owner_to_years[owner].union(years) >+ >+ result = [] >+ >+ for owner, years in list(owner_to_years.items()): >+ sorted_years = list(years) >+ sorted_years.sort() >+ result.append("%s %s" % (', '.join(sorted_years), owner)) >+ >+ return result >+ >+ def all_functions(self): >+ result = [] >+ for object in self.objects: >+ result.extend(object.functions) >+ >+ result.sort() >+ return result >+ >+ def all_internal_functions(self): >+ result = [] >+ for object in [o for o in self.objects if 'internal' in o.annotations]: >+ result.extend(object.functions) >+ >+ result.sort() >+ return result >+ >+ # Private methods. >+ >+ def _parse_copyright_lines(self, text): >+ licenseBlock = multilineCommentRegExp.findall(text)[0] >+ licenseBlock = licenseBlock[:licenseBlock.index("Redistribution")] >+ >+ copyrightLines = [Templates.DefaultCopyright] >+ for line in licenseBlock.split("\n"): >+ line = line.replace("/*", "") >+ line = line.replace("*/", "") >+ line = line.replace("*", "") >+ line = line.replace("Copyright", "") >+ line = line.replace("copyright", "") >+ line = line.replace("(C)", "") >+ line = line.replace("(c)", "") >+ line = line.strip() >+ >+ if len(line) == 0: >+ continue >+ >+ copyrightLines.append(line) >+ >+ return copyrightLines >+ >+ def _parse_annotations(self, text): >+ annotations = {} >+ >+ for match in keyValueAnnotationCommentRegExp.finditer(text): >+ (key, value) = match.group(1, 2) >+ log.debug("Found annotation: '%s' => '%s'" % (key, value)) >+ if key in annotations: >+ raise ParseException("Duplicate annotation found: %s" % key) >+ >+ annotations[key] = value >+ >+ for match in flagAnnotationCommentRegExp.finditer(text): >+ key = match.group(1) >+ log.debug("Found annotation: '%s' => 'TRUE'" % key) >+ if key in annotations: >+ raise ParseException("Duplicate annotation found: %s" % key) >+ >+ annotations[key] = True >+ >+ return annotations >+ >+ def _parse_functions(self, text): >+ text = multilineCommentRegExp.sub("/**/", singleLineCommentRegExp.sub("//\n", text)) >+ >+ matches = [func for func in functionHeadRegExp.finditer(text)] >+ functionBounds = [] >+ start = 0 >+ end = 0 >+ for match in matches: >+ start = match.start() >+ if start < end: >+ continue >+ end = match.end() >+ while text[end] != '{': >+ end = end + 1 >+ depth = 1 >+ end = end + 1 >+ while depth > 0: >+ if text[end] == '{': >+ depth = depth + 1 >+ elif text[end] == '}': >+ depth = depth - 1 >+ end = end + 1 >+ functionBounds.append((start, end)) >+ >+ functionStrings = [text[start:end].strip() for (start, end) in functionBounds] >+ return list(map(BuiltinFunction.fromString, functionStrings)) >diff --git a/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_templates.py b/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_templates.py >new file mode 100644 >index 0000000000000000000000000000000000000000..907a6d717c910cb07299509c61df846a9c701efc >--- /dev/null >+++ b/Source/JavaScriptCore/Scripts/wkbuiltins/builtins_templates.py >@@ -0,0 +1,216 @@ >+#!/usr/bin/env python >+# >+# Copyright (c) 2014-2016 Apple Inc. All rights reserved. >+# Copyright (C) 2015 Canon 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: >+# 1. Redistributions of source code must retain the above copyright >+# notice, this list of conditions and the following disclaimer. >+# 2. 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. >+# >+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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. >+ >+# Builtins generator templates, which can be filled with string.Template. >+ >+ >+class BuiltinsGeneratorTemplates: >+ >+ DefaultCopyright = "2016 Apple Inc. All rights reserved." >+ LicenseText = ( >+ """Redistribution and use in source and binary forms, with or without >+modification, are permitted provided that the following conditions >+are met: >+1. Redistributions of source code must retain the above copyright >+ notice, this list of conditions and the following disclaimer. >+2. 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. >+ >+THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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. >+""") >+ >+ DoNotEditWarning = ( >+ """// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for >+// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py""") >+ >+ HeaderIncludeGuard = ( >+ """#pragma once""") >+ >+ NamespaceTop = ( >+ """namespace ${namespace} {""") >+ >+ NamespaceBottom = ( >+ """} // namespace ${namespace}""") >+ >+ CombinedHeaderStaticMacros = ( >+ """#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\ >+ JSC::FunctionExecutable* codeName##Generator(JSC::VM&); >+ >+${macroPrefix}_FOREACH_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR) >+#undef DECLARE_BUILTIN_GENERATOR""") >+ >+ SeparateHeaderStaticMacros = ( >+ """#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\ >+ JSC::FunctionExecutable* codeName##Generator(JSC::VM&); >+ >+${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR) >+#undef DECLARE_BUILTIN_GENERATOR""") >+ >+ CombinedJSCImplementationStaticMacros = ( >+ """ >+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\ >+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \\ >+{\\ >+ return vm.builtinExecutables()->codeName##Executable()->link(vm, vm.builtinExecutables()->codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \ >+} >+${macroPrefix}_FOREACH_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) >+#undef DEFINE_BUILTIN_GENERATOR >+""") >+ >+ SeparateJSCImplementationStaticMacros = ( >+ """ >+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\ >+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \\ >+{\\ >+ return vm.builtinExecutables()->codeName##Executable()->link(vm, vm.builtinExecutables()->codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \ >+} >+${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) >+#undef DEFINE_BUILTIN_GENERATOR >+""") >+ >+ CombinedWebCoreImplementationStaticMacros = ( >+ """ >+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\ >+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \\ >+{\\ >+ JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \\ >+ return clientData->builtinFunctions().${objectNameLC}Builtins().codeName##Executable()->link(vm, clientData->builtinFunctions().${objectNameLC}Builtins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \\ >+} >+${macroPrefix}_FOREACH_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) >+#undef DEFINE_BUILTIN_GENERATOR >+""") >+ >+ SeparateWebCoreImplementationStaticMacros = ( >+ """ >+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\ >+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \\ >+{\\ >+ JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \\ >+ return clientData->builtinFunctions().${objectNameLC}Builtins().codeName##Executable()->link(vm, clientData->builtinFunctions().${objectNameLC}Builtins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \\ >+} >+${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) >+#undef DEFINE_BUILTIN_GENERATOR >+""") >+ >+ SeparateHeaderWrapperBoilerplate = ( >+ """class ${objectName}BuiltinsWrapper : private JSC::WeakHandleOwner { >+public: >+ explicit ${objectName}BuiltinsWrapper(JSC::VM* vm) >+ : m_vm(*vm) >+ ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES) >+#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { })) >+ ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS) >+#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS >+ { >+ } >+ >+#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \\ >+ JSC::UnlinkedFunctionExecutable* name##Executable(); \\ >+ const JSC::SourceCode& name##Source() const { return m_##name##Source; } >+ ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES) >+#undef EXPOSE_BUILTIN_EXECUTABLES >+ >+ ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) >+ >+ void exportNames(); >+ >+private: >+ JSC::VM& m_vm; >+ >+ ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES) >+ >+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \\ >+ JSC::SourceCode m_##name##Source;\\ >+ JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable; >+ ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS) >+#undef DECLARE_BUILTIN_SOURCE_MEMBERS >+ >+}; >+ >+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \\ >+inline JSC::UnlinkedFunctionExecutable* ${objectName}BuiltinsWrapper::name##Executable() \\ >+{\\ >+ if (!m_##name##Executable) {\\ >+ JSC::Identifier executableName = functionName##PublicName();\\ >+ if (overriddenName)\\ >+ executableName = JSC::Identifier::fromString(&m_vm, overriddenName);\\ >+ m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructAbility), this, &m_##name##Executable);\\ >+ }\\ >+ return m_##name##Executable.get();\\ >+} >+${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES) >+#undef DEFINE_BUILTIN_EXECUTABLES >+ >+inline void ${objectName}BuiltinsWrapper::exportNames() >+{ >+#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName()); >+ ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME) >+#undef EXPORT_FUNCTION_NAME >+}""") >+ >+ SeparateHeaderInternalFunctionsBoilerplate = ( >+ """class ${objectName}BuiltinFunctions { >+public: >+ explicit ${objectName}BuiltinFunctions(JSC::VM& vm) : m_vm(vm) { } >+ >+ void init(JSC::JSGlobalObject&); >+ void visit(JSC::SlotVisitor&); >+ >+public: >+ JSC::VM& m_vm; >+ >+#define DECLARE_BUILTIN_SOURCE_MEMBERS(functionName) \\ >+ JSC::WriteBarrier<JSC::JSFunction> m_##functionName##Function; >+ ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_SOURCE_MEMBERS) >+#undef DECLARE_BUILTIN_SOURCE_MEMBERS >+}; >+ >+inline void ${objectName}BuiltinFunctions::init(JSC::JSGlobalObject& globalObject) >+{ >+#define EXPORT_FUNCTION(codeName, functionName, overriddenName, length)\\ >+ m_##functionName##Function.set(m_vm, &globalObject, JSC::JSFunction::create(m_vm, codeName##Generator(m_vm), &globalObject)); >+ ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(EXPORT_FUNCTION) >+#undef EXPORT_FUNCTION >+} >+ >+inline void ${objectName}BuiltinFunctions::visit(JSC::SlotVisitor& visitor) >+{ >+#define VISIT_FUNCTION(name) visitor.append(m_##name##Function); >+ ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_FUNCTION_NAME(VISIT_FUNCTION) >+#undef VISIT_FUNCTION >+} >+""") >diff --git a/Source/JavaScriptCore/Scripts/wkbuiltins/wkbuiltins.py b/Source/JavaScriptCore/Scripts/wkbuiltins/wkbuiltins.py >new file mode 100644 >index 0000000000000000000000000000000000000000..a9aff2b1cff4f25350b7658dda49c0a5123e9c14 >--- /dev/null >+++ b/Source/JavaScriptCore/Scripts/wkbuiltins/wkbuiltins.py >@@ -0,0 +1,15 @@ >+# This file is used to simulate the builtins/ directory when generate-js-builtins.py >+# is run from JavaScriptCore framework's private headers directory, which is flattened. >+ >+from builtins_model import * >+from builtins_templates import * >+ >+from builtins_generator import * >+from builtins_generate_combined_header import * >+from builtins_generate_combined_implementation import * >+from builtins_generate_separate_header import * >+from builtins_generate_separate_implementation import * >+from builtins_generate_wrapper_header import * >+from builtins_generate_wrapper_implementation import * >+from builtins_generate_internals_wrapper_header import * >+from builtins_generate_internals_wrapper_implementation import * >diff --git a/Source/JavaScriptCore/disassembler/udis86/ud_opcode.py b/Source/JavaScriptCore/disassembler/udis86/ud_opcode.py >index fe1833dc71b74ef666d11efe4f827d49f6e82402..30c9f436cd637a71546453e29c052d8e34f2950b 100644 >--- a/Source/JavaScriptCore/disassembler/udis86/ud_opcode.py >+++ b/Source/JavaScriptCore/disassembler/udis86/ud_opcode.py >@@ -550,10 +550,10 @@ class UdOpcodeTables(object): > entries = tbl.entries() > for k, e in entries: > if isinstance(e, UdOpcodeTable): >- self.log("%s |-<%02x> %s" % (indent, k, e)) >+ self.log("%s |-<%02x> %s" % (indent, int(k), e)) > printWalk(e, indent + " |") > elif isinstance(e, UdInsnDef): >- self.log("%s |-<%02x> %s" % (indent, k, e)) >+ self.log("%s |-<%02x> %s" % (indent, int(k), e)) > printWalk(self.root) > > >diff --git a/Source/JavaScriptCore/generate-bytecode-files b/Source/JavaScriptCore/generate-bytecode-files >index fa25fd2ef31be4c1eb3c3a585be529d67cfed6d8..3fbd12f3fe8b124dbd45df2e150dc434f1645558 100644 >--- a/Source/JavaScriptCore/generate-bytecode-files >+++ b/Source/JavaScriptCore/generate-bytecode-files >@@ -94,6 +94,12 @@ def openOrExit(path, mode): > print("I/O error opening {0}, ({1}): {2}".format(path, e.errno, e.strerror)) > exit(1) > >+def dowrite(file, str): >+ if sys.version_info.major == 2: >+ file.write(str) >+ else: >+ file.write(bytes(str, "utf-8")) >+ > def hashFile(file): > sha1 = hashlib.sha1() > file.seek(0) >@@ -112,31 +118,31 @@ def toCpp(name): > > > def writeInstructionAccessor(bytecodeHFile, typeName, name): >- bytecodeHFile.write(" {0}& {1}() {{ return *bitwise_cast<{0}*>(&m_{1}); }}\n".format(typeName, name)) >- bytecodeHFile.write(" const {0}& {1}() const {{ return *bitwise_cast<const {0}*>(&m_{1}); }}\n".format(typeName, name)) >+ dowrite(bytecodeHFile, " {0}& {1}() {{ return *bitwise_cast<{0}*>(&m_{1}); }}\n".format(typeName, name)) >+ dowrite(bytecodeHFile, " const {0}& {1}() const {{ return *bitwise_cast<const {0}*>(&m_{1}); }}\n".format(typeName, name)) > > > def writeInstructionMember(bytecodeHFile, typeName, name): >- bytecodeHFile.write(" std::aligned_storage<sizeof({0}), sizeof(Instruction)>::type m_{1};\n".format(typeName, name)) >- bytecodeHFile.write(" static_assert(sizeof({0}) <= sizeof(Instruction), \"Size of {0} shouldn't be bigger than an Instruction.\");\n".format(typeName, name)) >+ dowrite(bytecodeHFile, " std::aligned_storage<sizeof({0}), sizeof(Instruction)>::type m_{1};\n".format(typeName, name)) >+ dowrite(bytecodeHFile, " static_assert(sizeof({0}) <= sizeof(Instruction), \"Size of {0} shouldn't be bigger than an Instruction.\");\n".format(typeName, name)) > > def writeStruct(bytecodeHFile, bytecode): >- bytecodeHFile.write("struct {0} {{\n".format(toCpp(bytecode["name"]))) >- bytecodeHFile.write("public:\n") >+ dowrite(bytecodeHFile, "struct {0} {{\n".format(toCpp(bytecode["name"]))) >+ dowrite(bytecodeHFile, "public:\n") > > writeInstructionAccessor(bytecodeHFile, "Opcode", "opcode") > for offset in bytecode["offsets"]: >- for name, typeName in offset.iteritems(): >+ for name, typeName in offset.items(): > writeInstructionAccessor(bytecodeHFile, typeName, name) > >- bytecodeHFile.write("\nprivate:\n") >- bytecodeHFile.write(" friend class LLIntOffsetsExtractor;\n\n") >+ dowrite(bytecodeHFile, "\nprivate:\n") >+ dowrite(bytecodeHFile, " friend class LLIntOffsetsExtractor;\n\n") > > writeInstructionMember(bytecodeHFile, "Opcode", "opcode") > for offset in bytecode["offsets"]: >- for name, typeName in offset.iteritems(): >+ for name, typeName in offset.items(): > writeInstructionMember(bytecodeHFile, typeName, name) >- bytecodeHFile.write("};\n\n") >+ dowrite(bytecodeHFile, "};\n\n") > > > if __name__ == "__main__": >@@ -220,25 +226,25 @@ if __name__ == "__main__": > print("Unexpected error parsing {0}: {1}".format(bytecodeJSONFile, sys.exc_info())) > > if bytecodeHFilename: >- bytecodeHFile.write(hFileHashString) >- bytecodeHFile.write(cCopyrightMsg % bytecodeJSONFile) >- bytecodeHFile.write("#pragma once\n\n") >+ dowrite(bytecodeHFile, hFileHashString) >+ dowrite(bytecodeHFile, cCopyrightMsg % bytecodeJSONFile) >+ dowrite(bytecodeHFile, "#pragma once\n\n") > > if bytecodeStructsHFilename: >- bytecodeStructsHFile.write(hFileHashString) >- bytecodeStructsHFile.write(cCopyrightMsg % bytecodeJSONFile) >- bytecodeStructsHFile.write("#pragma once\n\n") >- bytecodeStructsHFile.write("#include \"Instruction.h\"\n") >- bytecodeStructsHFile.write("\n") >+ dowrite(bytecodeStructsHFile, hFileHashString) >+ dowrite(bytecodeStructsHFile, cCopyrightMsg % bytecodeJSONFile) >+ dowrite(bytecodeStructsHFile, "#pragma once\n\n") >+ dowrite(bytecodeStructsHFile, "#include \"Instruction.h\"\n") >+ dowrite(bytecodeStructsHFile, "\n") > > if initASMFileName: >- initBytecodesFile.write(asmFileHashString) >- initBytecodesFile.write(asmCopyrightMsg % bytecodeJSONFile) >+ dowrite(initBytecodesFile, asmFileHashString) >+ dowrite(initBytecodesFile, asmCopyrightMsg % bytecodeJSONFile) > initASMBytecodeNum = 0 > > for section in bytecodeSections: > if bytecodeHFilename and section['emitInHFile']: >- bytecodeHFile.write("#define FOR_EACH_{0}_ID(macro) \\\n".format(section["macroNameComponent"])) >+ dowrite(bytecodeHFile, "#define FOR_EACH_{0}_ID(macro) \\\n".format(section["macroNameComponent"])) > firstMacro = True > defaultLength = 1 > if "defaultLength" in section: >@@ -247,7 +253,7 @@ if __name__ == "__main__": > bytecodeNum = 0 > for bytecode in section["bytecodes"]: > if not firstMacro: >- bytecodeHFile.write(" \\\n") >+ dowrite(bytecodeHFile, " \\\n") > > length = defaultLength > if "length" in bytecode: >@@ -256,39 +262,39 @@ if __name__ == "__main__": > # Add one for the opcode > length = len(bytecode["offsets"]) + 1 > >- bytecodeHFile.write(" macro({0}, {1})".format(bytecode["name"], length)) >+ dowrite(bytecodeHFile, " macro({0}, {1})".format(bytecode["name"], length)) > firstMacro = False > bytecodeNum = bytecodeNum + 1 > >- bytecodeHFile.write("\n\n") >- bytecodeHFile.write("#define NUMBER_OF_{0}_IDS {1}\n\n".format(section["macroNameComponent"], bytecodeNum)) >+ dowrite(bytecodeHFile, "\n\n") >+ dowrite(bytecodeHFile, "#define NUMBER_OF_{0}_IDS {1}\n\n".format(section["macroNameComponent"], bytecodeNum)) > > > if bytecodeStructsHFilename and section['emitInStructsFile']: >- bytecodeStructsHFile.write("namespace JSC {\n\n") >+ dowrite(bytecodeStructsHFile, "namespace JSC {\n\n") > > for bytecode in section["bytecodes"]: > if not "offsets" in bytecode: > continue > writeStruct(bytecodeStructsHFile, bytecode) > >- bytecodeStructsHFile.write("} // namespace JSC \n") >+ dowrite(bytecodeStructsHFile, "} // namespace JSC \n") > > if bytecodeHFilename and section['emitOpcodeIDStringValuesInHFile']: > bytecodeNum = 0 > for bytecode in section["bytecodes"]: >- bytecodeHFile.write("#define {0}_value_string \"{1}\"\n".format(bytecode["name"], bytecodeNum)) >+ dowrite(bytecodeHFile, "#define {0}_value_string \"{1}\"\n".format(bytecode["name"], bytecodeNum)) > firstMacro = False > bytecodeNum = bytecodeNum + 1 > >- bytecodeHFile.write("\n") >+ dowrite(bytecodeHFile, "\n") > > if initASMFileName and section['emitInASMFile']: > prefix = "" > if "asmPrefix" in section: > prefix = section["asmPrefix"] > for bytecode in section["bytecodes"]: >- initBytecodesFile.write("setEntryAddress({0}, _{1}{2})\n".format(initASMBytecodeNum, prefix, bytecode["name"])) >+ dowrite(initBytecodesFile, "setEntryAddress({0}, _{1}{2})\n".format(initASMBytecodeNum, prefix, bytecode["name"])) > initASMBytecodeNum = initASMBytecodeNum + 1 > > if bytecodeHFilename: >diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/__init__.py b/Source/JavaScriptCore/inspector/scripts/codegen/__init__.py >index 37dbe94363328b3e0160f0bc011fea01ec3e834e..1a4ac69da4b5f1e9dd17f1bc93709333d7e26c19 100644 >--- a/Source/JavaScriptCore/inspector/scripts/codegen/__init__.py >+++ b/Source/JavaScriptCore/inspector/scripts/codegen/__init__.py >@@ -1,25 +1,25 @@ > # Required for Python to search this directory for module files > >-from models import * >-from generator import * >-from cpp_generator import * >-from objc_generator import * >+from .models import * >+from .generator import * >+from .cpp_generator import * >+from .objc_generator import * > >-from generate_cpp_alternate_backend_dispatcher_header import * >-from generate_cpp_backend_dispatcher_header import * >-from generate_cpp_backend_dispatcher_implementation import * >-from generate_cpp_frontend_dispatcher_header import * >-from generate_cpp_frontend_dispatcher_implementation import * >-from generate_cpp_protocol_types_header import * >-from generate_cpp_protocol_types_implementation import * >-from generate_js_backend_commands import * >-from generate_objc_backend_dispatcher_header import * >-from generate_objc_backend_dispatcher_implementation import * >-from generate_objc_configuration_header import * >-from generate_objc_configuration_implementation import * >-from generate_objc_frontend_dispatcher_implementation import * >-from generate_objc_header import * >-from generate_objc_internal_header import * >-from generate_objc_protocol_types_implementation import * >-from generate_objc_protocol_type_conversions_header import * >-from generate_objc_protocol_type_conversions_implementation import * >+from .generate_cpp_alternate_backend_dispatcher_header import * >+from .generate_cpp_backend_dispatcher_header import * >+from .generate_cpp_backend_dispatcher_implementation import * >+from .generate_cpp_frontend_dispatcher_header import * >+from .generate_cpp_frontend_dispatcher_implementation import * >+from .generate_cpp_protocol_types_header import * >+from .generate_cpp_protocol_types_implementation import * >+from .generate_js_backend_commands import * >+from .generate_objc_backend_dispatcher_header import * >+from .generate_objc_backend_dispatcher_implementation import * >+from .generate_objc_configuration_header import * >+from .generate_objc_configuration_implementation import * >+from .generate_objc_frontend_dispatcher_implementation import * >+from .generate_objc_header import * >+from .generate_objc_internal_header import * >+from .generate_objc_protocol_types_implementation import * >+from .generate_objc_protocol_type_conversions_header import * >+from .generate_objc_protocol_type_conversions_implementation import * >diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/cpp_generator.py b/Source/JavaScriptCore/inspector/scripts/codegen/cpp_generator.py >index 5f2e9c8462d80322f5cab955881b98a5aa508b34..a7d274481199af0ec42cab06481b6258f10a27e9 100644 >--- a/Source/JavaScriptCore/inspector/scripts/codegen/cpp_generator.py >+++ b/Source/JavaScriptCore/inspector/scripts/codegen/cpp_generator.py >@@ -28,8 +28,8 @@ import logging > import os.path > import re > >-from generator import ucfirst, Generator >-from models import PrimitiveType, ObjectType, ArrayType, EnumType, AliasedType, Frameworks >+from .generator import ucfirst, Generator >+from .models import PrimitiveType, ObjectType, ArrayType, EnumType, AliasedType, Frameworks > > log = logging.getLogger('global') > >diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py >index f6bf86da92a4b65e98eb105b9ce3694d4f15d7d7..2769df8542bddcd69f147e0e0585177ca863f4dd 100755 >--- a/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py >+++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py >@@ -30,8 +30,8 @@ import string > import re > from string import Template > >-from cpp_generator import CppGenerator >-from cpp_generator_templates import CppGeneratorTemplates as CppTemplates >+from .cpp_generator import CppGenerator >+from .cpp_generator_templates import CppGeneratorTemplates as CppTemplates > > log = logging.getLogger('global') > >@@ -52,7 +52,7 @@ class CppAlternateBackendDispatcherHeaderGenerator(CppGenerator): > sections = [] > sections.append(self.generate_license()) > sections.append(Template(CppTemplates.AlternateDispatchersHeaderPrelude).substitute(None, **template_args)) >- sections.append('\n'.join(filter(None, map(self._generate_handler_declarations_for_domain, domains)))) >+ sections.append('\n'.join([_f for _f in map(self._generate_handler_declarations_for_domain, domains) if _f])) > sections.append(Template(CppTemplates.AlternateDispatchersHeaderPostlude).substitute(None, **template_args)) > return '\n\n'.join(sections) > >diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py >index 0769c8a27a973dc5fe3b1780c4d37daa84d4eb74..c14ab18eff2333489c0af2a7fc1f9d1bb73ec0c5 100755 >--- a/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py >+++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py >@@ -30,10 +30,10 @@ import re > import string > from string import Template > >-from cpp_generator import CppGenerator >-from cpp_generator_templates import CppGeneratorTemplates as CppTemplates >-from generator import Generator, ucfirst >-from models import EnumType >+from .cpp_generator import CppGenerator >+from .cpp_generator_templates import CppGeneratorTemplates as CppTemplates >+from .generator import Generator, ucfirst >+from .models import EnumType > > log = logging.getLogger('global') > >@@ -46,7 +46,7 @@ class CppBackendDispatcherHeaderGenerator(CppGenerator): > return "%sBackendDispatchers.h" % self.protocol_name() > > def domains_to_generate(self): >- return filter(lambda domain: len(self.commands_for_domain(domain)) > 0, Generator.domains_to_generate(self)) >+ return [domain for domain in Generator.domains_to_generate(self) if len(self.commands_for_domain(domain)) > 0] > > def generate_output(self): > typedefs = [('String', 'ErrorString')] >@@ -62,8 +62,8 @@ class CppBackendDispatcherHeaderGenerator(CppGenerator): > sections.append(Template(CppTemplates.HeaderPrelude).substitute(None, **header_args)) > if self.model().framework.setting('alternate_dispatchers', False): > sections.append(self._generate_alternate_handler_forward_declarations_for_domains(domains)) >- sections.extend(map(self._generate_handler_declarations_for_domain, domains)) >- sections.extend(map(self._generate_dispatcher_declarations_for_domain, domains)) >+ sections.extend(list(map(self._generate_handler_declarations_for_domain, domains))) >+ sections.extend(list(map(self._generate_dispatcher_declarations_for_domain, domains))) > sections.append(Template(CppTemplates.HeaderPostlude).substitute(None, **header_args)) > return "\n\n".join(sections) > >@@ -198,7 +198,7 @@ class CppBackendDispatcherHeaderGenerator(CppGenerator): > commands = self.commands_for_domain(domain) > if len(commands) > 0: > declarations.append('private:') >- declarations.extend(map(self._generate_dispatcher_declaration_for_command, commands)) >+ declarations.extend(list(map(self._generate_dispatcher_declaration_for_command, commands))) > > declaration_args = { > 'domainName': domain.domain_name, >diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py >index c558ed4edb022cceb929f2be6496b4aa46b1cb82..034bd72828259bc88d8374c5c3d3800ebc74bed0 100755 >--- a/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py >+++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py >@@ -29,10 +29,10 @@ import logging > import string > from string import Template > >-from cpp_generator import CppGenerator >-from cpp_generator_templates import CppGeneratorTemplates as CppTemplates >-from generator import Generator, ucfirst >-from models import ObjectType, ArrayType >+from .cpp_generator import CppGenerator >+from .cpp_generator_templates import CppGeneratorTemplates as CppTemplates >+from .generator import Generator, ucfirst >+from .models import ObjectType, ArrayType > > log = logging.getLogger('global') > >@@ -45,7 +45,7 @@ class CppBackendDispatcherImplementationGenerator(CppGenerator): > return "%sBackendDispatchers.cpp" % self.protocol_name() > > def domains_to_generate(self): >- return filter(lambda domain: len(self.commands_for_domain(domain)) > 0, Generator.domains_to_generate(self)) >+ return [domain for domain in Generator.domains_to_generate(self) if len(self.commands_for_domain(domain)) > 0] > > def generate_output(self): > secondary_includes = self._generate_secondary_header_includes() >@@ -65,7 +65,7 @@ class CppBackendDispatcherImplementationGenerator(CppGenerator): > sections.append(self.generate_license()) > sections.append(Template(CppTemplates.ImplementationPrelude).substitute(None, **header_args)) > sections.append("\n".join(map(self._generate_handler_class_destructor_for_domain, self.domains_to_generate()))) >- sections.extend(map(self._generate_dispatcher_implementations_for_domain, self.domains_to_generate())) >+ sections.extend(list(map(self._generate_dispatcher_implementations_for_domain, self.domains_to_generate()))) > sections.append(Template(CppTemplates.ImplementationPostlude).substitute(None, **header_args)) > return "\n\n".join(sections) > >diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py >index 59bd7666098302fea33eb5953630cbaf26817422..90bdbcd77683c1af27bc06d93c999cf2283f51bc 100755 >--- a/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py >+++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py >@@ -30,10 +30,10 @@ import re > import string > from string import Template > >-from cpp_generator import CppGenerator >-from cpp_generator_templates import CppGeneratorTemplates as CppTemplates >-from generator import Generator, ucfirst >-from models import EnumType >+from .cpp_generator import CppGenerator >+from .cpp_generator_templates import CppGeneratorTemplates as CppTemplates >+from .generator import Generator, ucfirst >+from .models import EnumType > > log = logging.getLogger('global') > >@@ -46,7 +46,7 @@ class CppFrontendDispatcherHeaderGenerator(CppGenerator): > return "%sFrontendDispatchers.h" % self.protocol_name() > > def domains_to_generate(self): >- return filter(lambda domain: len(self.events_for_domain(domain)) > 0, Generator.domains_to_generate(self)) >+ return [domain for domain in Generator.domains_to_generate(self) if len(self.events_for_domain(domain)) > 0] > > def generate_output(self): > header_args = { >@@ -57,7 +57,7 @@ class CppFrontendDispatcherHeaderGenerator(CppGenerator): > sections = [] > sections.append(self.generate_license()) > sections.append(Template(CppTemplates.HeaderPrelude).substitute(None, **header_args)) >- sections.extend(map(self._generate_dispatcher_declarations_for_domain, self.domains_to_generate())) >+ sections.extend(list(map(self._generate_dispatcher_declarations_for_domain, self.domains_to_generate()))) > sections.append(Template(CppTemplates.HeaderPostlude).substitute(None, **header_args)) > return "\n\n".join(sections) > >diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py >index b6965f57f3bff9b372c273c3ebe9c7a5a6e8d953..2cffd2b829d2510f4c7e560049fb2b8884db4abf 100755 >--- a/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py >+++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py >@@ -29,10 +29,10 @@ import logging > import string > from string import Template > >-from cpp_generator import CppGenerator >-from cpp_generator_templates import CppGeneratorTemplates as CppTemplates >-from generator import Generator, ucfirst >-from models import ObjectType, ArrayType >+from .cpp_generator import CppGenerator >+from .cpp_generator_templates import CppGeneratorTemplates as CppTemplates >+from .generator import Generator, ucfirst >+from .models import ObjectType, ArrayType > > log = logging.getLogger('global') > >@@ -45,7 +45,7 @@ class CppFrontendDispatcherImplementationGenerator(CppGenerator): > return "%sFrontendDispatchers.cpp" % self.protocol_name() > > def domains_to_generate(self): >- return filter(lambda domain: len(self.events_for_domain(domain)) > 0, Generator.domains_to_generate(self)) >+ return [domain for domain in Generator.domains_to_generate(self) if len(self.events_for_domain(domain)) > 0] > > def generate_output(self): > header_args = { >@@ -56,7 +56,7 @@ class CppFrontendDispatcherImplementationGenerator(CppGenerator): > sections = [] > sections.append(self.generate_license()) > sections.append(Template(CppTemplates.ImplementationPrelude).substitute(None, **header_args)) >- sections.extend(map(self._generate_dispatcher_implementations_for_domain, self.domains_to_generate())) >+ sections.extend(list(map(self._generate_dispatcher_implementations_for_domain, self.domains_to_generate()))) > sections.append(Template(CppTemplates.ImplementationPostlude).substitute(None, **header_args)) > return "\n\n".join(sections) > >diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_header.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_header.py >index 7548d63145acd81d9a52e121d9127a8e80453e78..f90c100aacd5f0f124e010797b7dedc0ba347d99 100755 >--- a/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_header.py >+++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_header.py >@@ -31,10 +31,10 @@ import string > from operator import methodcaller > from string import Template > >-from cpp_generator import CppGenerator >-from cpp_generator_templates import CppGeneratorTemplates as CppTemplates >-from generator import Generator, ucfirst >-from models import EnumType, ObjectType, PrimitiveType, AliasedType, ArrayType, Frameworks >+from .cpp_generator import CppGenerator >+from .cpp_generator_templates import CppGeneratorTemplates as CppTemplates >+from .generator import Generator, ucfirst >+from .models import EnumType, ObjectType, PrimitiveType, AliasedType, ArrayType, Frameworks > > log = logging.getLogger('global') > >@@ -62,8 +62,8 @@ class CppProtocolTypesHeaderGenerator(CppGenerator): > sections.append(self._generate_forward_declarations(domains)) > sections.append(self._generate_typedefs(domains)) > sections.extend(self._generate_enum_constant_value_conversion_methods()) >- builder_sections = map(self._generate_builders_for_domain, domains) >- sections.extend(filter(lambda section: len(section) > 0, builder_sections)) >+ builder_sections = list(map(self._generate_builders_for_domain, domains)) >+ sections.extend([section for section in builder_sections if len(section) > 0]) > sections.append(self._generate_forward_declarations_for_binding_traits(domains)) > sections.extend(self._generate_declarations_for_enum_conversion_methods(domains)) > sections.append('} // namespace Protocol') >@@ -88,8 +88,8 @@ class CppProtocolTypesHeaderGenerator(CppGenerator): > > for domain in domains: > declaration_types = [decl.type for decl in self.type_declarations_for_domain(domain)] >- object_types = filter(lambda _type: isinstance(_type, ObjectType), declaration_types) >- enum_types = filter(lambda _type: isinstance(_type, EnumType), declaration_types) >+ object_types = [_type for _type in declaration_types if isinstance(_type, ObjectType)] >+ enum_types = [_type for _type in declaration_types if isinstance(_type, EnumType)] > sorted(object_types, key=methodcaller('raw_name')) > sorted(enum_types, key=methodcaller('raw_name')) > >@@ -114,8 +114,8 @@ class CppProtocolTypesHeaderGenerator(CppGenerator): > """ % '\n\n'.join(sections) > > def _generate_typedefs(self, domains): >- sections = map(self._generate_typedefs_for_domain, domains) >- sections = filter(lambda text: len(text) > 0, sections) >+ sections = list(map(self._generate_typedefs_for_domain, domains)) >+ sections = [text for text in sections if len(text) > 0] > > if len(sections) == 0: > return '' >@@ -126,8 +126,8 @@ class CppProtocolTypesHeaderGenerator(CppGenerator): > > def _generate_typedefs_for_domain(self, domain): > type_declarations = self.type_declarations_for_domain(domain) >- primitive_declarations = filter(lambda decl: isinstance(decl.type, AliasedType), type_declarations) >- array_declarations = filter(lambda decl: isinstance(decl.type, ArrayType), type_declarations) >+ primitive_declarations = [decl for decl in type_declarations if isinstance(decl.type, AliasedType)] >+ array_declarations = [decl for decl in type_declarations if isinstance(decl.type, ArrayType)] > if len(primitive_declarations) == 0 and len(array_declarations) == 0: > return '' > >@@ -187,7 +187,7 @@ class CppProtocolTypesHeaderGenerator(CppGenerator): > elif isinstance(type_declaration.type, ObjectType): > sections.append(self._generate_class_for_object_declaration(type_declaration, domain)) > >- sections = filter(lambda section: len(section) > 0, sections) >+ sections = [section for section in sections if len(section) > 0] > if len(sections) == 0: > return '' > >@@ -201,9 +201,9 @@ class CppProtocolTypesHeaderGenerator(CppGenerator): > if len(type_declaration.type_members) == 0: > return '' > >- enum_members = filter(lambda member: isinstance(member.type, EnumType) and member.type.is_anonymous, type_declaration.type_members) >- required_members = filter(lambda member: not member.is_optional, type_declaration.type_members) >- optional_members = filter(lambda member: member.is_optional, type_declaration.type_members) >+ enum_members = [member for member in type_declaration.type_members if isinstance(member.type, EnumType) and member.type.is_anonymous] >+ required_members = [member for member in type_declaration.type_members if not member.is_optional] >+ optional_members = [member for member in type_declaration.type_members if member.is_optional] > object_name = type_declaration.type_name > > lines = [] >@@ -262,7 +262,7 @@ class CppProtocolTypesHeaderGenerator(CppGenerator): > else: > return ' ' + line > >- indented_lines = map(apply_indentation, self._generate_struct_for_enum_type(enum_member.member_name, enum_member.type)) >+ indented_lines = list(map(apply_indentation, self._generate_struct_for_enum_type(enum_member.member_name, enum_member.type))) > return '\n'.join(indented_lines) > > def _generate_struct_for_enum_type(self, enum_name, enum_type): >@@ -276,7 +276,7 @@ class CppProtocolTypesHeaderGenerator(CppGenerator): > > def _generate_builder_state_enum(self, type_declaration): > lines = [] >- required_members = filter(lambda member: not member.is_optional, type_declaration.type_members) >+ required_members = [member for member in type_declaration.type_members if not member.is_optional] > enum_values = [] > > lines.append(' enum {') >@@ -344,7 +344,7 @@ class CppProtocolTypesHeaderGenerator(CppGenerator): > > for domain in domains: > type_declarations = self.type_declarations_for_domain(domain) >- declarations_to_generate = filter(lambda decl: self.type_needs_shape_assertions(decl.type), type_declarations) >+ declarations_to_generate = [decl for decl in type_declarations if self.type_needs_shape_assertions(decl.type)] > > for type_declaration in declarations_to_generate: > for type_member in type_declaration.type_members: >@@ -393,8 +393,8 @@ class CppProtocolTypesHeaderGenerator(CppGenerator): > for domain in domains: > type_declarations = self.type_declarations_for_domain(domain) > declaration_types = [decl.type for decl in type_declarations] >- object_types = filter(lambda _type: isinstance(_type, ObjectType), declaration_types) >- enum_types = filter(lambda _type: isinstance(_type, EnumType), declaration_types) >+ object_types = [_type for _type in declaration_types if isinstance(_type, ObjectType)] >+ enum_types = [_type for _type in declaration_types if isinstance(_type, EnumType)] > if len(object_types) + len(enum_types) == 0: > continue > >diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py >index 5e7aec23ae6e247271e8dc10d29d770c63a9ec27..ac8ec5b710cc3dfb56dc9aaff5ce94030e8506a2 100755 >--- a/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py >+++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py >@@ -30,10 +30,10 @@ import string > from string import Template > from operator import methodcaller > >-from cpp_generator import CppGenerator >-from cpp_generator_templates import CppGeneratorTemplates as CppTemplates >-from generator import Generator, ucfirst >-from models import AliasedType, ArrayType, EnumType, ObjectType >+from .cpp_generator import CppGenerator >+from .cpp_generator_templates import CppGeneratorTemplates as CppTemplates >+from .generator import Generator, ucfirst >+from .models import AliasedType, ArrayType, EnumType, ObjectType > > log = logging.getLogger('global') > >@@ -65,8 +65,8 @@ class CppProtocolTypesImplementationGenerator(CppGenerator): > sections.append('namespace Protocol {') > sections.extend(self._generate_enum_mapping_and_conversion_methods(domains)) > sections.append(self._generate_open_field_names()) >- builder_sections = map(self._generate_builders_for_domain, domains) >- sections.extend(filter(lambda section: len(section) > 0, builder_sections)) >+ builder_sections = list(map(self._generate_builders_for_domain, domains)) >+ sections.extend([section for section in builder_sections if len(section) > 0]) > sections.append('} // namespace Protocol') > sections.append(Template(CppTemplates.ImplementationPostlude).substitute(None, **header_args)) > >@@ -128,8 +128,8 @@ class CppProtocolTypesImplementationGenerator(CppGenerator): > > type_declarations = self.type_declarations_for_domain(domain) > declaration_types = [decl.type for decl in type_declarations] >- object_types = filter(lambda _type: isinstance(_type, ObjectType), declaration_types) >- enum_types = filter(lambda _type: isinstance(_type, EnumType), declaration_types) >+ object_types = [_type for _type in declaration_types if isinstance(_type, ObjectType)] >+ enum_types = [_type for _type in declaration_types if isinstance(_type, EnumType)] > if len(object_types) + len(enum_types) == 0: > return '' > >@@ -156,8 +156,8 @@ class CppProtocolTypesImplementationGenerator(CppGenerator): > sections = [] > sections.append('namespace %s {' % self.helpers_namespace()) > sections.extend(self._generate_enum_mapping()) >- enum_parser_sections = map(self._generate_enum_conversion_methods_for_domain, domains) >- sections.extend(filter(lambda section: len(section) > 0, enum_parser_sections)) >+ enum_parser_sections = list(map(self._generate_enum_conversion_methods_for_domain, domains)) >+ sections.extend([section for section in enum_parser_sections if len(section) > 0]) > if len(sections) == 1: > return [] # No declarations to emit, just the namespace. > >@@ -168,7 +168,7 @@ class CppProtocolTypesImplementationGenerator(CppGenerator): > lines = [] > for domain in self.domains_to_generate(): > type_declarations = self.type_declarations_for_domain(domain) >- for type_declaration in filter(lambda decl: Generator.type_has_open_fields(decl.type), type_declarations): >+ for type_declaration in [decl for decl in type_declarations if Generator.type_has_open_fields(decl.type)]: > open_members = Generator.open_fields(type_declaration) > for type_member in sorted(open_members, key=lambda member: member.member_name): > field_name = '::'.join(['Inspector', 'Protocol', domain.domain_name, ucfirst(type_declaration.type_name), ucfirst(type_member.member_name)]) >@@ -179,7 +179,7 @@ class CppProtocolTypesImplementationGenerator(CppGenerator): > def _generate_builders_for_domain(self, domain): > sections = [] > type_declarations = self.type_declarations_for_domain(domain) >- declarations_to_generate = filter(lambda decl: self.type_needs_shape_assertions(decl.type), type_declarations) >+ declarations_to_generate = [decl for decl in type_declarations if self.type_needs_shape_assertions(decl.type)] > > for type_declaration in declarations_to_generate: > for type_member in type_declaration.type_members: >@@ -200,8 +200,8 @@ class CppProtocolTypesImplementationGenerator(CppGenerator): > return Template(CppTemplates.ProtocolObjectRuntimeCast).substitute(None, **args) > > def _generate_assertion_for_object_declaration(self, object_declaration): >- required_members = filter(lambda member: not member.is_optional, object_declaration.type_members) >- optional_members = filter(lambda member: member.is_optional, object_declaration.type_members) >+ required_members = [member for member in object_declaration.type_members if not member.is_optional] >+ optional_members = [member for member in object_declaration.type_members if member.is_optional] > should_count_properties = not Generator.type_has_open_fields(object_declaration.type) > lines = [] > >diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_js_backend_commands.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_js_backend_commands.py >index 93307a8972d2c9eb70a7b13470c398b6dd9f186d..907bf0ca38cffadb6d7d3a876a62e6c27c9e6516 100755 >--- a/Source/JavaScriptCore/inspector/scripts/codegen/generate_js_backend_commands.py >+++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_js_backend_commands.py >@@ -30,9 +30,9 @@ import logging > import string > from string import Template > >-from generator import Generator, ucfirst >-from generator_templates import GeneratorTemplates as Templates >-from models import EnumType >+from .generator import Generator, ucfirst >+from .generator_templates import GeneratorTemplates as Templates >+from .models import EnumType > > log = logging.getLogger('global') > >@@ -46,16 +46,16 @@ class JSBackendCommandsGenerator(Generator): > > def should_generate_domain(self, domain): > type_declarations = self.type_declarations_for_domain(domain) >- domain_enum_types = filter(lambda declaration: isinstance(declaration.type, EnumType), type_declarations) >+ domain_enum_types = [declaration for declaration in type_declarations if isinstance(declaration.type, EnumType)] > return len(self.commands_for_domain(domain)) > 0 or len(self.events_for_domain(domain)) > 0 or len(domain_enum_types) > 0 > > def domains_to_generate(self): >- return filter(self.should_generate_domain, Generator.domains_to_generate(self)) >+ return list(filter(self.should_generate_domain, Generator.domains_to_generate(self))) > > def generate_output(self): > sections = [] > sections.append(self.generate_license()) >- sections.extend(map(self.generate_domain, self.domains_to_generate())) >+ sections.extend(list(map(self.generate_domain, self.domains_to_generate()))) > return "\n\n".join(sections) > > def generate_domain(self, domain): >@@ -70,7 +70,7 @@ class JSBackendCommandsGenerator(Generator): > commands = self.commands_for_domain(domain) > events = self.events_for_domain(domain) > >- has_async_commands = any(map(lambda command: command.is_async, commands)) >+ has_async_commands = any([command.is_async for command in commands]) > if len(events) > 0 or has_async_commands: > lines.append('InspectorBackend.register%(domain)sDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "%(domain)s");' % args) > >diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py >index 00357567e8cd797f1b1a945e1aebc8693c04cde2..6146d7726d1e5751a6b22a93a37f63006eccb269 100755 >--- a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py >+++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py >@@ -30,11 +30,11 @@ import string > import re > from string import Template > >-from cpp_generator import CppGenerator >-from generator import Generator >-from models import Frameworks >-from objc_generator import ObjCGenerator >-from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates >+from .cpp_generator import CppGenerator >+from .generator import Generator >+from .models import Frameworks >+from .objc_generator import ObjCGenerator >+from .objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates > > log = logging.getLogger('global') > >@@ -47,7 +47,7 @@ class ObjCBackendDispatcherHeaderGenerator(ObjCGenerator): > return '%sBackendDispatchers.h' % self.protocol_name() > > def domains_to_generate(self): >- return filter(self.should_generate_commands_for_domain, Generator.domains_to_generate(self)) >+ return list(filter(self.should_generate_commands_for_domain, Generator.domains_to_generate(self))) > > def generate_output(self): > headers = [ >@@ -64,7 +64,7 @@ class ObjCBackendDispatcherHeaderGenerator(ObjCGenerator): > sections = [] > sections.append(self.generate_license()) > sections.append(Template(ObjCTemplates.BackendDispatcherHeaderPrelude).substitute(None, **header_args)) >- sections.extend(map(self._generate_objc_handler_declarations_for_domain, domains)) >+ sections.extend(list(map(self._generate_objc_handler_declarations_for_domain, domains))) > sections.append(Template(ObjCTemplates.BackendDispatcherHeaderPostlude).substitute(None, **header_args)) > return '\n\n'.join(sections) > >diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py >index ad5616516bb5d258d7ee46f79a7fef97cda6d4a2..d99e9cc7e64dd409a97029236ee650e4b38c28b4 100755 >--- a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py >+++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py >@@ -30,11 +30,11 @@ import string > import re > from string import Template > >-from cpp_generator import CppGenerator >-from generator import Generator >-from models import PrimitiveType, EnumType, AliasedType, Frameworks >-from objc_generator import ObjCTypeCategory, ObjCGenerator, join_type_and_name >-from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates >+from .cpp_generator import CppGenerator >+from .generator import Generator >+from .models import PrimitiveType, EnumType, AliasedType, Frameworks >+from .objc_generator import ObjCTypeCategory, ObjCGenerator, join_type_and_name >+from .objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates > > log = logging.getLogger('global') > >@@ -47,7 +47,7 @@ class ObjCBackendDispatcherImplementationGenerator(ObjCGenerator): > return '%sBackendDispatchers.mm' % self.protocol_name() > > def domains_to_generate(self): >- return filter(self.should_generate_commands_for_domain, Generator.domains_to_generate(self)) >+ return list(filter(self.should_generate_commands_for_domain, Generator.domains_to_generate(self))) > > def generate_output(self): > secondary_headers = [ >@@ -65,7 +65,7 @@ class ObjCBackendDispatcherImplementationGenerator(ObjCGenerator): > sections = [] > sections.append(self.generate_license()) > sections.append(Template(ObjCTemplates.BackendDispatcherImplementationPrelude).substitute(None, **header_args)) >- sections.extend(map(self._generate_handler_implementation_for_domain, domains)) >+ sections.extend(list(map(self._generate_handler_implementation_for_domain, domains))) > sections.append(Template(ObjCTemplates.BackendDispatcherImplementationPostlude).substitute(None, **header_args)) > return '\n\n'.join(sections) > >@@ -114,7 +114,7 @@ class ObjCBackendDispatcherImplementationGenerator(ObjCGenerator): > if command.return_parameters: > lines.append(' Ref<JSON::Object> resultObject = JSON::Object::create();') > >- required_pointer_parameters = filter(lambda parameter: not parameter.is_optional and ObjCGenerator.is_type_objc_pointer_type(parameter.type), command.return_parameters) >+ required_pointer_parameters = [parameter for parameter in command.return_parameters if not parameter.is_optional and ObjCGenerator.is_type_objc_pointer_type(parameter.type)] > for parameter in required_pointer_parameters: > var_name = ObjCGenerator.identifier_to_objc_identifier(parameter.parameter_name) > lines.append(' THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(%s, @"%s");' % (var_name, var_name)) >@@ -122,7 +122,7 @@ class ObjCBackendDispatcherImplementationGenerator(ObjCGenerator): > if objc_array_class and objc_array_class.startswith(self.objc_prefix()): > lines.append(' THROW_EXCEPTION_FOR_BAD_TYPE_IN_ARRAY(%s, [%s class]);' % (var_name, objc_array_class)) > >- optional_pointer_parameters = filter(lambda parameter: parameter.is_optional and ObjCGenerator.is_type_objc_pointer_type(parameter.type), command.return_parameters) >+ optional_pointer_parameters = [parameter for parameter in command.return_parameters if parameter.is_optional and ObjCGenerator.is_type_objc_pointer_type(parameter.type)] > for parameter in optional_pointer_parameters: > var_name = ObjCGenerator.identifier_to_objc_identifier(parameter.parameter_name) > lines.append(' THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(%s, @"%s");' % (var_name, var_name)) >diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_configuration_header.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_configuration_header.py >index a232e2ce439a3d763fbfb94b914b6e7dfe41b70b..00448b0f02c8464082cd326041656f0831e7fe88 100755 >--- a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_configuration_header.py >+++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_configuration_header.py >@@ -29,9 +29,9 @@ import logging > import string > from string import Template > >-from generator import Generator >-from objc_generator import ObjCGenerator >-from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates >+from .generator import Generator >+from .objc_generator import ObjCGenerator >+from .objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates > > log = logging.getLogger('global') > >diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_configuration_implementation.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_configuration_implementation.py >index 910bcbab1350d076e95e53dc0ab98dc47b2bcd34..9935877aecec258c281d11caf0acbb76cabae182 100755 >--- a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_configuration_implementation.py >+++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_configuration_implementation.py >@@ -29,9 +29,9 @@ import logging > import string > from string import Template > >-from generator import Generator >-from objc_generator import ObjCGenerator >-from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates >+from .generator import Generator >+from .objc_generator import ObjCGenerator >+from .objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates > > log = logging.getLogger('global') > >diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py >index 654f9b4bf8a4406ff53a0b3db170fda4d406751d..0fefd7a6ee2617a37217b017eda3944afbbc147f 100755 >--- a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py >+++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py >@@ -29,10 +29,10 @@ import logging > import string > from string import Template > >-from cpp_generator import CppGenerator >-from generator import Generator, ucfirst >-from objc_generator import ObjCGenerator >-from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates >+from .cpp_generator import CppGenerator >+from .generator import Generator, ucfirst >+from .objc_generator import ObjCGenerator >+from .objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates > > log = logging.getLogger('global') > >@@ -45,7 +45,7 @@ class ObjCFrontendDispatcherImplementationGenerator(ObjCGenerator): > return '%sEventDispatchers.mm' % self.protocol_name() > > def domains_to_generate(self): >- return filter(self.should_generate_events_for_domain, Generator.domains_to_generate(self)) >+ return list(filter(self.should_generate_events_for_domain, Generator.domains_to_generate(self))) > > def generate_output(self): > secondary_headers = [ >@@ -62,7 +62,7 @@ class ObjCFrontendDispatcherImplementationGenerator(ObjCGenerator): > sections = [] > sections.append(self.generate_license()) > sections.append(Template(ObjCTemplates.ImplementationPrelude).substitute(None, **header_args)) >- sections.extend(map(self._generate_event_dispatcher_implementations, domains)) >+ sections.extend(list(map(self._generate_event_dispatcher_implementations, domains))) > sections.append(Template(ObjCTemplates.ImplementationPostlude).substitute(None, **header_args)) > return '\n\n'.join(sections) > >@@ -100,7 +100,7 @@ class ObjCFrontendDispatcherImplementationGenerator(ObjCGenerator): > lines.append(' const FrontendRouter& router = _controller->frontendRouter();') > lines.append('') > >- required_pointer_parameters = filter(lambda parameter: not parameter.is_optional and ObjCGenerator.is_type_objc_pointer_type(parameter.type), event.event_parameters) >+ required_pointer_parameters = [parameter for parameter in event.event_parameters if not parameter.is_optional and ObjCGenerator.is_type_objc_pointer_type(parameter.type)] > for parameter in required_pointer_parameters: > var_name = ObjCGenerator.identifier_to_objc_identifier(parameter.parameter_name) > lines.append(' THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(%s, @"%s");' % (var_name, var_name)) >@@ -108,7 +108,7 @@ class ObjCFrontendDispatcherImplementationGenerator(ObjCGenerator): > if objc_array_class and objc_array_class.startswith(self.objc_prefix()): > lines.append(' THROW_EXCEPTION_FOR_BAD_TYPE_IN_ARRAY(%s, [%s class]);' % (var_name, objc_array_class)) > >- optional_pointer_parameters = filter(lambda parameter: parameter.is_optional and ObjCGenerator.is_type_objc_pointer_type(parameter.type), event.event_parameters) >+ optional_pointer_parameters = [parameter for parameter in event.event_parameters if parameter.is_optional and ObjCGenerator.is_type_objc_pointer_type(parameter.type)] > for parameter in optional_pointer_parameters: > var_name = ObjCGenerator.identifier_to_objc_identifier(parameter.parameter_name) > lines.append(' THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(%s, @"%s");' % (var_name, var_name)) >diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_header.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_header.py >index a8343e6e63eed49bdde7b572a5f717f25d8cd1ac..0a99e2f68baa55cec063c305bea4d153bb30acd9 100755 >--- a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_header.py >+++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_header.py >@@ -29,10 +29,10 @@ import logging > import string > from string import Template > >-from generator import Generator, ucfirst >-from models import ObjectType, EnumType, Platforms >-from objc_generator import ObjCGenerator, join_type_and_name >-from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates >+from .generator import Generator, ucfirst >+from .models import ObjectType, EnumType, Platforms >+from .objc_generator import ObjCGenerator, join_type_and_name >+from .objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates > > log = logging.getLogger('global') > >@@ -60,9 +60,9 @@ class ObjCHeaderGenerator(ObjCGenerator): > } > > domains = self.domains_to_generate() >- type_domains = filter(self.should_generate_types_for_domain, domains) >- command_domains = filter(self.should_generate_commands_for_domain, domains) >- event_domains = filter(self.should_generate_events_for_domain, domains) >+ type_domains = list(filter(self.should_generate_types_for_domain, domains)) >+ command_domains = list(filter(self.should_generate_commands_for_domain, domains)) >+ event_domains = list(filter(self.should_generate_events_for_domain, domains)) > > # FIXME: <https://webkit.org/b/138222> Web Inspector: Reduce unnecessary enums/types generated in ObjC Protocol Interfaces > # Currently we generate enums/types for all types in the type_domains. For the built-in >@@ -72,14 +72,14 @@ class ObjCHeaderGenerator(ObjCGenerator): > sections = [] > sections.append(self.generate_license()) > sections.append(Template(ObjCTemplates.HeaderPrelude).substitute(None, **header_args)) >- sections.append('\n'.join(filter(None, map(self._generate_forward_declarations, type_domains)))) >+ sections.append('\n'.join([_f for _f in map(self._generate_forward_declarations, type_domains) if _f])) > sections.append(self._generate_enum_for_platforms()) >- sections.append('\n'.join(filter(None, map(self._generate_enums, type_domains)))) >- sections.append('\n'.join(filter(None, map(self._generate_types, type_domains)))) >+ sections.append('\n'.join([_f for _f in map(self._generate_enums, type_domains) if _f])) >+ sections.append('\n'.join([_f for _f in map(self._generate_types, type_domains) if _f])) > > if self.get_generator_setting('generate_backend', False): >- sections.append('\n\n'.join(filter(None, map(self._generate_command_protocols, command_domains)))) >- sections.append('\n\n'.join(filter(None, map(self._generate_event_interfaces, event_domains)))) >+ sections.append('\n\n'.join([_f for _f in map(self._generate_command_protocols, command_domains) if _f])) >+ sections.append('\n\n'.join([_f for _f in map(self._generate_event_interfaces, event_domains) if _f])) > > sections.append(Template(ObjCTemplates.HeaderPostlude).substitute(None)) > return '\n\n'.join(sections) >@@ -171,8 +171,8 @@ class ObjCHeaderGenerator(ObjCGenerator): > lines.append('- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload;') > lines.append('- (instancetype)initWithProtocolObject:(RWIProtocolJSONObject *)jsonObject;') > >- required_members = filter(lambda member: not member.is_optional, declaration.type_members) >- optional_members = filter(lambda member: member.is_optional, declaration.type_members) >+ required_members = [member for member in declaration.type_members if not member.is_optional] >+ optional_members = [member for member in declaration.type_members if member.is_optional] > if required_members: > lines.append(self._generate_init_method_for_required_members(domain, declaration, required_members)) > for member in required_members: >diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_internal_header.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_internal_header.py >index b6e4ad5e918b30d470d6ed99b1642e96932b94e3..bd4d1fc1074b01eec2f976f8534489d5c2d0ad5d 100755 >--- a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_internal_header.py >+++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_internal_header.py >@@ -29,9 +29,9 @@ import logging > import string > from string import Template > >-from generator import Generator, ucfirst >-from objc_generator import ObjCGenerator >-from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates >+from .generator import Generator, ucfirst >+from .objc_generator import ObjCGenerator >+from .objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates > > log = logging.getLogger('global') > >@@ -55,12 +55,12 @@ class ObjCInternalHeaderGenerator(ObjCGenerator): > 'includes': '\n'.join(['#import ' + header for header in sorted(headers)]), > } > >- event_domains = filter(self.should_generate_events_for_domain, self.domains_to_generate()) >+ event_domains = list(filter(self.should_generate_events_for_domain, self.domains_to_generate())) > > sections = [] > sections.append(self.generate_license()) > sections.append(Template(ObjCTemplates.GenericHeaderPrelude).substitute(None, **header_args)) >- sections.append('\n\n'.join(filter(None, map(self._generate_event_dispatcher_private_interfaces, event_domains)))) >+ sections.append('\n\n'.join([_f for _f in map(self._generate_event_dispatcher_private_interfaces, event_domains) if _f])) > sections.append(Template(ObjCTemplates.GenericHeaderPostlude).substitute(None, **header_args)) > return '\n\n'.join(sections) > >diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_header.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_header.py >index 84cbdda177312c6c69333e7a0ed1a6ae54ff9c4d..482e4ecc5e76f59a6740e433df5ef6080d2afa49 100755 >--- a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_header.py >+++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_header.py >@@ -29,10 +29,10 @@ import logging > import string > from string import Template > >-from generator import Generator >-from models import EnumType, Frameworks, Platforms >-from objc_generator import ObjCGenerator >-from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates >+from .generator import Generator >+from .models import EnumType, Frameworks, Platforms >+from .objc_generator import ObjCGenerator >+from .objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates > > log = logging.getLogger('global') > >@@ -51,7 +51,7 @@ class ObjCProtocolTypeConversionsHeaderGenerator(ObjCGenerator): > return '%sTypeConversions.h' % self.protocol_name() > > def domains_to_generate(self): >- return filter(self.should_generate_types_for_domain, Generator.domains_to_generate(self)) >+ return list(filter(self.should_generate_types_for_domain, Generator.domains_to_generate(self))) > > def generate_output(self): > headers = [ >@@ -70,7 +70,7 @@ class ObjCProtocolTypeConversionsHeaderGenerator(ObjCGenerator): > sections.append(Template(ObjCTemplates.TypeConversionsHeaderPrelude).substitute(None, **header_args)) > sections.append(Template(ObjCTemplates.TypeConversionsHeaderStandard).substitute(None)) > sections.append(self._generate_enum_conversion_for_platforms()) >- sections.extend(map(self._generate_enum_conversion_functions, domains)) >+ sections.extend(list(map(self._generate_enum_conversion_functions, domains))) > sections.append(Template(ObjCTemplates.TypeConversionsHeaderPostlude).substitute(None, **header_args)) > return '\n\n'.join(sections) > >diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_implementation.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_implementation.py >index 4293e3bd84cf93793f715e82eb16a255733ea9f8..694f98461a988dd043a67d015dbb1ae717f60237 100644 >--- a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_implementation.py >+++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_implementation.py >@@ -28,10 +28,10 @@ import logging > import string > from string import Template > >-from generator import Generator >-from models import EnumType, ObjectType, ArrayType, AliasedType, PrimitiveType, Frameworks >-from objc_generator import ObjCGenerator >-from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates >+from .generator import Generator >+from .models import EnumType, ObjectType, ArrayType, AliasedType, PrimitiveType, Frameworks >+from .objc_generator import ObjCGenerator >+from .objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates > > log = logging.getLogger('global') > >@@ -50,7 +50,7 @@ class ObjCProtocolTypeConversionsImplementationGenerator(ObjCGenerator): > return '%sTypeConversions.mm' % self.protocol_name() > > def domains_to_generate(self): >- return filter(self.should_generate_types_for_domain, Generator.domains_to_generate(self)) >+ return list(filter(self.should_generate_types_for_domain, Generator.domains_to_generate(self))) > > def generate_output(self): > secondary_headers = [ >diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_types_implementation.py b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_types_implementation.py >index 0ba55ee8d418abd57bb119f0dc3f444704c8d117..bd5f11e54c61ddb5cedbf980cdadbfc9cf12dc99 100755 >--- a/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_types_implementation.py >+++ b/Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_types_implementation.py >@@ -29,10 +29,10 @@ import logging > import string > from string import Template > >-from generator import Generator, ucfirst >-from models import ObjectType, EnumType, Frameworks >-from objc_generator import ObjCTypeCategory, ObjCGenerator >-from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates >+from .generator import Generator, ucfirst >+from .models import ObjectType, EnumType, Frameworks >+from .objc_generator import ObjCTypeCategory, ObjCGenerator >+from .objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates > > log = logging.getLogger('global') > >@@ -51,7 +51,7 @@ class ObjCProtocolTypesImplementationGenerator(ObjCGenerator): > return '%sTypes.mm' % self.protocol_name() > > def domains_to_generate(self): >- return filter(self.should_generate_types_for_domain, Generator.domains_to_generate(self)) >+ return list(filter(self.should_generate_types_for_domain, Generator.domains_to_generate(self))) > > def generate_output(self): > secondary_headers = [ >@@ -75,7 +75,7 @@ class ObjCProtocolTypesImplementationGenerator(ObjCGenerator): > sections = [] > sections.append(self.generate_license()) > sections.append(Template(ObjCTemplates.ImplementationPrelude).substitute(None, **header_args)) >- sections.extend(map(self.generate_type_implementations, domains)) >+ sections.extend(list(map(self.generate_type_implementations, domains))) > sections.append(Template(ObjCTemplates.ImplementationPostlude).substitute(None, **header_args)) > return '\n\n'.join(sections) > >@@ -95,7 +95,7 @@ class ObjCProtocolTypesImplementationGenerator(ObjCGenerator): > lines.append('') > lines.append(self._generate_init_method_for_payload(domain, declaration)) > lines.append(self._generate_init_method_for_protocol_object(domain, declaration)) >- required_members = filter(lambda member: not member.is_optional, declaration.type_members) >+ required_members = [member for member in declaration.type_members if not member.is_optional] > if required_members: > lines.append('') > lines.append(self._generate_init_method_for_required_members(domain, declaration, required_members)) >@@ -167,7 +167,7 @@ class ObjCProtocolTypesImplementationGenerator(ObjCGenerator): > lines.append(' return nil;') > lines.append('') > >- required_pointer_members = filter(lambda member: ObjCGenerator.is_type_objc_pointer_type(member.type), required_members) >+ required_pointer_members = [member for member in required_members if ObjCGenerator.is_type_objc_pointer_type(member.type)] > if required_pointer_members: > for member in required_pointer_members: > var_name = ObjCGenerator.identifier_to_objc_identifier(member.member_name) >diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/generator.py b/Source/JavaScriptCore/inspector/scripts/codegen/generator.py >index eed218dc2f053a67751c2c935633195d38dbf85b..f5cd819a7af222cb0b4ab1b01dac3948397697a1 100755 >--- a/Source/JavaScriptCore/inspector/scripts/codegen/generator.py >+++ b/Source/JavaScriptCore/inspector/scripts/codegen/generator.py >@@ -29,8 +29,8 @@ import os.path > import re > from string import Template > >-from generator_templates import GeneratorTemplates as Templates >-from models import PrimitiveType, ObjectType, ArrayType, EnumType, AliasedType, Frameworks, Platforms >+from .generator_templates import GeneratorTemplates as Templates >+from .models import PrimitiveType, ObjectType, ArrayType, EnumType, AliasedType, Frameworks, Platforms > > log = logging.getLogger('global') > >@@ -140,7 +140,7 @@ class Generator: > > # These methods are overridden by subclasses. > def non_supplemental_domains(self): >- return filter(lambda domain: not domain.is_supplemental, self.model().domains) >+ return [domain for domain in self.model().domains if not domain.is_supplemental] > > def domains_to_generate(self): > return self.non_supplemental_domains() >@@ -176,7 +176,7 @@ class Generator: > fields = set(_TYPES_WITH_OPEN_FIELDS.get(type_declaration.type.qualified_name(), [])) > if not fields: > return type_declaration.type_members >- return filter(lambda member: member.member_name in fields, type_declaration.type_members) >+ return [member for member in type_declaration.type_members if member.member_name in fields] > > def type_needs_shape_assertions(self, _type): > if not hasattr(self, "_types_needing_shape_assertions"): >@@ -189,7 +189,7 @@ class Generator: > # set of types will not be automatically regenerated on subsequent calls to > # Generator.types_needing_shape_assertions(). > def calculate_types_requiring_shape_assertions(self, domains): >- domain_names = map(lambda domain: domain.domain_name, domains) >+ domain_names = [domain.domain_name for domain in domains] > log.debug("> Calculating types that need shape assertions (eligible domains: %s)" % ", ".join(domain_names)) > > # Mutates the passed-in set; this simplifies checks to prevent infinite recursion. >@@ -245,7 +245,7 @@ class Generator: > for _type in all_types: > if not isinstance(_type, EnumType): > continue >- map(self._assign_encoding_for_enum_value, _type.enum_values()) >+ list(map(self._assign_encoding_for_enum_value, _type.enum_values())) > > def _assign_encoding_for_enum_value(self, enum_value): > if enum_value in self._enum_value_encodings: >@@ -279,7 +279,7 @@ class Generator: > return _ALWAYS_SPECIALCASED_ENUM_VALUE_LOOKUP_TABLE[match.group(1).upper()] > > # Split on hyphen, introduce camelcase, and force uppercasing of acronyms. >- subwords = map(ucfirst, _ENUM_IDENTIFIER_RENAME_MAP.get(enum_value, enum_value).split('-')) >+ subwords = list(map(ucfirst, _ENUM_IDENTIFIER_RENAME_MAP.get(enum_value, enum_value).split('-'))) > return re.sub(re.compile(regex, re.IGNORECASE), replaceCallback, "".join(subwords)) > > @staticmethod >diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/models.py b/Source/JavaScriptCore/inspector/scripts/codegen/models.py >index ca91d71c7c5cc39a0f1c70370971893e03ec987a..d09b242f8bfd1f7dba84556b793b8478edc8057c 100755 >--- a/Source/JavaScriptCore/inspector/scripts/codegen/models.py >+++ b/Source/JavaScriptCore/inspector/scripts/codegen/models.py >@@ -35,7 +35,7 @@ def ucfirst(str): > > > def find_duplicates(l): >- return [key for key, count in collections.Counter(l).items() if count > 1] >+ return [key for key, count in list(collections.Counter(l).items()) if count > 1] > > > _FRAMEWORK_CONFIG_MAP = { >diff --git a/Source/JavaScriptCore/inspector/scripts/codegen/objc_generator.py b/Source/JavaScriptCore/inspector/scripts/codegen/objc_generator.py >index e52f31544c11fb76c4baac67e7ba9272240cfcd7..e4ce01f81ab3b4fe935f867129ca50bdffb6a33d 100755 >--- a/Source/JavaScriptCore/inspector/scripts/codegen/objc_generator.py >+++ b/Source/JavaScriptCore/inspector/scripts/codegen/objc_generator.py >@@ -24,8 +24,8 @@ > # THE POSSIBILITY OF SUCH DAMAGE. > > import logging >-from generator import Generator, ucfirst >-from models import PrimitiveType, ObjectType, ArrayType, EnumType, AliasedType, Frameworks >+from .generator import Generator, ucfirst >+from .models import PrimitiveType, ObjectType, ArrayType, EnumType, AliasedType, Frameworks > > log = logging.getLogger('global') > >@@ -50,7 +50,7 @@ _OBJC_IDENTIFIER_RENAME_MAP = { > 'id': 'identifier', # Page.Frame.id, Runtime.ExecutionContextDescription.id, Debugger.BreakpointAction.id > } > >-_OBJC_IDENTIFIER_REVERSE_RENAME_MAP = dict((v, k) for k, v in _OBJC_IDENTIFIER_RENAME_MAP.iteritems()) >+_OBJC_IDENTIFIER_REVERSE_RENAME_MAP = dict((v, k) for k, v in _OBJC_IDENTIFIER_RENAME_MAP.items()) > > > class ObjCTypeCategory: >diff --git a/Source/JavaScriptCore/wasm/generateWasm.py b/Source/JavaScriptCore/wasm/generateWasm.py >index 16887ecf95efddf6bf54feb5b7e78558ed2a37a3..f0b6b58be481d195f86a757693b3d539561c176a 100755 >--- a/Source/JavaScriptCore/wasm/generateWasm.py >+++ b/Source/JavaScriptCore/wasm/generateWasm.py >@@ -71,7 +71,7 @@ class Wasm: > # We need to do this because python is dumb and won't let me use self in the lambda, which is ridiculous. > if ret == None: > ret = lambda op: {"name": op, "opcode": self.opcodes[op]} >- for op in self.opcodes.iterkeys(): >+ for op in self.opcodes.keys(): > if filter(self.opcodes[op]): > yield ret(op) > >diff --git a/Source/JavaScriptCore/yarr/generateYarrCanonicalizeUnicode b/Source/JavaScriptCore/yarr/generateYarrCanonicalizeUnicode >index a103bcdf16d21316932437f20ad341d8e08da024..052b9d112508b23b7e11946d19a307499578f62b 100644 >--- a/Source/JavaScriptCore/yarr/generateYarrCanonicalizeUnicode >+++ b/Source/JavaScriptCore/yarr/generateYarrCanonicalizeUnicode >@@ -31,7 +31,6 @@ import optparse > import os > import re > import sys >-from sets import Set > > header = """/* > * Copyright (C) 2016 Apple Inc. All rights reserved. >@@ -78,11 +77,21 @@ def openOrExit(path, mode): > dirname = os.path.dirname(path) > if not os.path.isdir(dirname): > os.makedirs(dirname) >- return open(path, mode) >+ if sys.version_info.major == 2 or mode == "wb" or mode == "rb": >+ return open(path, mode) >+ else: >+ return open(path, mode, encoding = "UTF-8") > except IOError as e: >- print "I/O error opening {0}, ({1}): {2}".format(path, e.errno, e.strerror) >+ print("I/O error opening {0}, ({1}): {2}".format(path, e.errno, e.strerror)) > exit(1) > >+def dowrite(file, str): >+ if sys.version_info.major == 2: >+ file.write(str) >+ else: >+ file.write(bytes(str, "utf-8")) >+ >+ > class Canonicalize: > def __init__(self): > self.canonicalGroups = {}; >@@ -93,7 +102,7 @@ class Canonicalize: > self.canonicalGroups[mapping].append(code) > > def readCaseFolding(self, file): >- codesSeen = Set() >+ codesSeen = set() > for line in file: > line = line.split('#', 1)[0] > line = line.rstrip() >@@ -157,26 +166,26 @@ class Canonicalize: > set = characterSets[i] > for ch in set: > characters = characters + "0x{character:04x}, ".format(character=ch) >- file.write("const UChar32 unicodeCharacterSet{index:d}[] = {{ {characters}0 }};\n".format(index=i, characters=characters)) >+ dowrite(file, "const UChar32 unicodeCharacterSet{index:d}[] = {{ {characters}0 }};\n".format(index=i, characters=characters)) > >- file.write("\n") >- file.write("static const size_t UNICODE_CANONICALIZATION_SETS = {setCount:d};\n".format(setCount=len(characterSets))) >- file.write("const UChar32* const unicodeCharacterSetInfo[UNICODE_CANONICALIZATION_SETS] = {\n") >+ dowrite(file, "\n") >+ dowrite(file, "static const size_t UNICODE_CANONICALIZATION_SETS = {setCount:d};\n".format(setCount=len(characterSets))) >+ dowrite(file, "const UChar32* const unicodeCharacterSetInfo[UNICODE_CANONICALIZATION_SETS] = {\n") > > for i in range(len(characterSets)): >- file.write(" unicodeCharacterSet{setNumber:d},\n".format(setNumber=i)) >+ dowrite(file, " unicodeCharacterSet{setNumber:d},\n".format(setNumber=i)) > >- file.write("};\n") >- file.write("\n") >- file.write("const size_t UNICODE_CANONICALIZATION_RANGES = {rangeCount:d};\n".format(rangeCount=len(rangeInfo))) >- file.write("const CanonicalizationRange unicodeRangeInfo[UNICODE_CANONICALIZATION_RANGES] = {\n") >+ dowrite(file, "};\n") >+ dowrite(file, "\n") >+ dowrite(file, "const size_t UNICODE_CANONICALIZATION_RANGES = {rangeCount:d};\n".format(rangeCount=len(rangeInfo))) >+ dowrite(file, "const CanonicalizationRange unicodeRangeInfo[UNICODE_CANONICALIZATION_RANGES] = {\n") > > for info in rangeInfo: > typeAndValue = info["type"].split(":") >- file.write(" {{ 0x{begin:04x}, 0x{end:04x}, 0x{value:04x}, {type} }},\n".format(begin=info["begin"], end=info["end"], value=int(typeAndValue[1]), type=typeAndValue[0])) >+ dowrite(file, " {{ 0x{begin:04x}, 0x{end:04x}, 0x{value:04x}, {type} }},\n".format(begin=info["begin"], end=info["end"], value=int(typeAndValue[1]), type=typeAndValue[0])) > >- file.write("};\n") >- file.write("\n") >+ dowrite(file, "};\n") >+ dowrite(file, "\n") > > > if __name__ == "__main__": >@@ -194,9 +203,9 @@ if __name__ == "__main__": > canonicalize = Canonicalize() > canonicalize.readCaseFolding(caseFoldingTxtFile) > >- canonicalizeHFile.write(header); >+ dowrite(canonicalizeHFile, header) > canonicalize.createTables(canonicalizeHFile) >- canonicalizeHFile.write(footer); >+ dowrite(canonicalizeHFile, footer) > > caseFoldingTxtFile.close() > canonicalizeHFile.close() >diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt >index a9c4a5f4347046cdacebbf8a1cb381a3f514856d..32d4af671147a908d5bb71cbf2d33f4a2f16b9da 100644 >--- a/Source/WebCore/CMakeLists.txt >+++ b/Source/WebCore/CMakeLists.txt >@@ -1850,7 +1850,7 @@ set(WebCore_BUILTINS_SOURCES > ) > > set(BUILTINS_GENERATOR_SCRIPTS >- ${JavaScriptCore_SCRIPTS_DIR}/builtins.py >+ ${JavaScriptCore_SCRIPTS_DIR}/wkbuiltins.py > ${JavaScriptCore_SCRIPTS_DIR}/builtins_generator.py > ${JavaScriptCore_SCRIPTS_DIR}/builtins_model.py > ${JavaScriptCore_SCRIPTS_DIR}/builtins_templates.py >diff --git a/Source/WebCore/platform/network/create-http-header-name-table b/Source/WebCore/platform/network/create-http-header-name-table >index ea2b74336483b050638713fd5173a6b09b8d6070..0dc19f6bff34c89bfe8c3ded20d6e889d1167ca5 100755 >--- a/Source/WebCore/platform/network/create-http-header-name-table >+++ b/Source/WebCore/platform/network/create-http-header-name-table >@@ -42,7 +42,7 @@ input_file = open(input_path) > http_header_name_to_id = { } > http_header_names = [] > >-for line in input_file.xreadlines(): >+for line in input_file: > http_header_name = line.strip() > if not http_header_name or http_header_name[:2] == '//': > continue >diff --git a/Source/WebInspectorUI/Scripts/copy-user-interface-resources.pl b/Source/WebInspectorUI/Scripts/copy-user-interface-resources.pl >index eb311c684e0add0a231608d159bab1e23e212fb3..00c38c1f319c89431a796ee559be7abb2d036fe4 100755 >--- a/Source/WebInspectorUI/Scripts/copy-user-interface-resources.pl >+++ b/Source/WebInspectorUI/Scripts/copy-user-interface-resources.pl >@@ -176,6 +176,8 @@ my $eslintLicense = readLicenseFile(File::Spec->catfile($eslintPath, 'LICENSE')) > my $threejsLicense = readLicenseFile(File::Spec->catfile($threejsPath, 'LICENSE')); > make_path($protocolDir, $targetResourcePath); > >+$python = $ENV{"PYTHON"} if defined($ENV{"PYTHON"}); >+ > # Copy over dynamically loaded files from other frameworks, even if we aren't combining resources. > copy(File::Spec->catfile($ENV{'JAVASCRIPTCORE_PRIVATE_HEADERS_DIR'}, 'InspectorBackendCommands.js'), File::Spec->catfile($protocolDir, 'InspectorBackendCommands.js')) or die "Copy of InspectorBackendCommands.js failed: $!"; > >diff --git a/Source/cmake/WebKitCommon.cmake b/Source/cmake/WebKitCommon.cmake >index 3843374a87a98f8afb0975d4fe1981020c22719f..d99f79e78cb421ec5d525f74f944afe97819642f 100644 >--- a/Source/cmake/WebKitCommon.cmake >+++ b/Source/cmake/WebKitCommon.cmake >@@ -21,9 +21,6 @@ if (NOT HAS_RUN_WEBKIT_COMMON) > find_package(PerlModules COMPONENTS JSON::PP REQUIRED) > > find_package(PythonInterp 2.7.0 REQUIRED) >- if (PYTHON_VERSION_MAJOR GREATER 2) >- message(FATAL_ERROR "Python 2 is required, but Python ${PYTHON_VERSION_MAJOR} was found.") >- endif () > > # We cannot check for RUBY_FOUND because it is set only when the full package is installed and > # the only thing we need is the interpreter. Unlike Python, cmake does not provide a macro >diff --git a/ChangeLog b/ChangeLog >index 1f2ea2ba64451f6f95c3d7bf74f7899f541737ae..05d30f736ffdffc240403cb7e233569e049f9273 100644 >--- a/ChangeLog >+++ b/ChangeLog >@@ -1,3 +1,12 @@ >+2018-08-27 Mike Gorse <mgorse@suse.com> >+ >+ Build tools should work when the /usr/bin/python is python3 >+ https://bugs.webkit.org/show_bug.cgi?id=156674 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Source/cmake/WebKitCommon.cmake: >+ > 2018-08-27 Michael Catanzaro <mcatanzaro@igalia.com> > > Unreviewed, bump WPE/GTK version numbers
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
mcatanzaro
:
review-
mcatanzaro
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 156674
:
335141
|
346638
|
347950
|
348154
|
350121
|
350303
|
350816