WebKit Bugzilla
Attachment 346638 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]
Revised patch.
python3.patch (text/plain), 182.64 KB, created by
Mike Gorse
on 2018-08-06 11:54:19 PDT
(
hide
)
Description:
Revised patch.
Filename:
MIME Type:
Creator:
Mike Gorse
Created:
2018-08-06 11:54:19 PDT
Size:
182.64 KB
patch
obsolete
>Index: Source/JavaScriptCore/CMakeLists.txt >=================================================================== >--- Source/JavaScriptCore/CMakeLists.txt (revision 234555) >+++ Source/JavaScriptCore/CMakeLists.txt (working copy) >@@ -136,7 +136,8 @@ > 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. >@@ -1085,7 +1086,7 @@ > # 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 >Index: Source/JavaScriptCore/Scripts/builtins/__init__.py >=================================================================== >--- Source/JavaScriptCore/Scripts/builtins/__init__.py (revision 234555) >+++ Source/JavaScriptCore/Scripts/builtins/__init__.py (nonexistent) >@@ -1,3 +0,0 @@ >-# Required for Python to search this directory for module files >- >-from builtins import * >Index: Source/JavaScriptCore/Scripts/builtins/builtins.py >=================================================================== >--- Source/JavaScriptCore/Scripts/builtins/builtins.py (revision 234555) >+++ Source/JavaScriptCore/Scripts/builtins/builtins.py (nonexistent) >@@ -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 * >Index: Source/JavaScriptCore/Scripts/builtins/builtins_generate_combined_header.py >=================================================================== >--- Source/JavaScriptCore/Scripts/builtins/builtins_generate_combined_header.py (revision 234555) >+++ Source/JavaScriptCore/Scripts/builtins/builtins_generate_combined_header.py (nonexistent) >@@ -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) > >Property changes on: Source/JavaScriptCore/Scripts/builtins/builtins_generate_combined_header.py >___________________________________________________________________ >Deleted: svn:executable >## -1 +0,0 ## >-* >\ No newline at end of property >Index: Source/JavaScriptCore/Scripts/builtins/builtins_generate_combined_implementation.py >=================================================================== >--- Source/JavaScriptCore/Scripts/builtins/builtins_generate_combined_implementation.py (revision 234555) >+++ Source/JavaScriptCore/Scripts/builtins/builtins_generate_combined_implementation.py (nonexistent) >@@ -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)) >Index: Source/JavaScriptCore/Scripts/builtins/builtins_generate_internals_wrapper_header.py >=================================================================== >--- Source/JavaScriptCore/Scripts/builtins/builtins_generate_internals_wrapper_header.py (revision 234555) >+++ Source/JavaScriptCore/Scripts/builtins/builtins_generate_internals_wrapper_header.py (nonexistent) >@@ -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) > >Property changes on: Source/JavaScriptCore/Scripts/builtins/builtins_generate_internals_wrapper_header.py >___________________________________________________________________ >Deleted: svn:executable >## -1 +0,0 ## >-* >\ No newline at end of property >Index: Source/JavaScriptCore/Scripts/builtins/builtins_generate_internals_wrapper_implementation.py >=================================================================== >--- Source/JavaScriptCore/Scripts/builtins/builtins_generate_internals_wrapper_implementation.py (revision 234555) >+++ Source/JavaScriptCore/Scripts/builtins/builtins_generate_internals_wrapper_implementation.py (nonexistent) >@@ -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) > >Property changes on: Source/JavaScriptCore/Scripts/builtins/builtins_generate_internals_wrapper_implementation.py >___________________________________________________________________ >Deleted: svn:executable >## -1 +0,0 ## >-* >\ No newline at end of property >Index: Source/JavaScriptCore/Scripts/builtins/builtins_generate_separate_header.py >=================================================================== >--- Source/JavaScriptCore/Scripts/builtins/builtins_generate_separate_header.py (revision 234555) >+++ Source/JavaScriptCore/Scripts/builtins/builtins_generate_separate_header.py (nonexistent) >@@ -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) > >Property changes on: Source/JavaScriptCore/Scripts/builtins/builtins_generate_separate_header.py >___________________________________________________________________ >Deleted: svn:executable >## -1 +0,0 ## >-* >\ No newline at end of property >Index: Source/JavaScriptCore/Scripts/builtins/builtins_generate_separate_implementation.py >=================================================================== >--- Source/JavaScriptCore/Scripts/builtins/builtins_generate_separate_implementation.py (revision 234555) >+++ Source/JavaScriptCore/Scripts/builtins/builtins_generate_separate_implementation.py (nonexistent) >@@ -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)) >Index: Source/JavaScriptCore/Scripts/builtins/builtins_generate_wrapper_header.py >=================================================================== >--- Source/JavaScriptCore/Scripts/builtins/builtins_generate_wrapper_header.py (revision 234555) >+++ Source/JavaScriptCore/Scripts/builtins/builtins_generate_wrapper_header.py (nonexistent) >@@ -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) > >Property changes on: Source/JavaScriptCore/Scripts/builtins/builtins_generate_wrapper_header.py >___________________________________________________________________ >Deleted: svn:executable >## -1 +0,0 ## >-* >\ No newline at end of property >Index: Source/JavaScriptCore/Scripts/builtins/builtins_generate_wrapper_implementation.py >=================================================================== >--- Source/JavaScriptCore/Scripts/builtins/builtins_generate_wrapper_implementation.py (revision 234555) >+++ Source/JavaScriptCore/Scripts/builtins/builtins_generate_wrapper_implementation.py (nonexistent) >@@ -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)) > >Property changes on: Source/JavaScriptCore/Scripts/builtins/builtins_generate_wrapper_implementation.py >___________________________________________________________________ >Deleted: svn:executable >## -1 +0,0 ## >-* >\ No newline at end of property >Index: Source/JavaScriptCore/Scripts/builtins/builtins_generator.py >=================================================================== >--- Source/JavaScriptCore/Scripts/builtins/builtins_generator.py (revision 234555) >+++ Source/JavaScriptCore/Scripts/builtins/builtins_generator.py (nonexistent) >@@ -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) >Index: Source/JavaScriptCore/Scripts/builtins/builtins_model.py >=================================================================== >--- Source/JavaScriptCore/Scripts/builtins/builtins_model.py (revision 234555) >+++ Source/JavaScriptCore/Scripts/builtins/builtins_model.py (nonexistent) >@@ -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) > >Property changes on: Source/JavaScriptCore/Scripts/builtins/builtins_model.py >___________________________________________________________________ >Deleted: svn:executable >## -1 +0,0 ## >-* >\ No newline at end of property >Index: Source/JavaScriptCore/Scripts/builtins/builtins_templates.py >=================================================================== >--- Source/JavaScriptCore/Scripts/builtins/builtins_templates.py (revision 234555) >+++ Source/JavaScriptCore/Scripts/builtins/builtins_templates.py (nonexistent) >@@ -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 >-} >-""") >Index: Source/JavaScriptCore/Scripts/cssmin.py >=================================================================== >--- Source/JavaScriptCore/Scripts/cssmin.py (revision 234555) >+++ Source/JavaScriptCore/Scripts/cssmin.py (working copy) >@@ -46,4 +46,7 @@ > 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())) >Index: Source/JavaScriptCore/Scripts/generate-js-builtins.py >=================================================================== >--- Source/JavaScriptCore/Scripts/generate-js-builtins.py (revision 234555) >+++ Source/JavaScriptCore/Scripts/generate-js-builtins.py (working copy) >@@ -31,6 +31,7 @@ > import logging > import optparse > import os >+import sys > > logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.ERROR) > log = logging.getLogger('global') >@@ -37,9 +38,8 @@ > > 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: > return framework_name + 'JSBuiltins.h-result' >@@ -46,6 +46,12 @@ > 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 @@ > 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 @@ > 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 @@ > > 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:") >Index: Source/JavaScriptCore/Scripts/generateIntlCanonicalizeLanguage.py >=================================================================== >--- Source/JavaScriptCore/Scripts/generateIntlCanonicalizeLanguage.py (revision 234555) >+++ Source/JavaScriptCore/Scripts/generateIntlCanonicalizeLanguage.py (working copy) >@@ -49,7 +49,13 @@ > 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 SubtagRegistry: > def __init__(self): > self.languageMap = {} >@@ -109,43 +115,43 @@ > > 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 +163,25 @@ > 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 +197,12 @@ > 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) >Index: Source/JavaScriptCore/Scripts/generateYarrUnicodePropertyTables.py >=================================================================== >--- Source/JavaScriptCore/Scripts/generateYarrUnicodePropertyTables.py (revision 234555) >+++ Source/JavaScriptCore/Scripts/generateYarrUnicodePropertyTables.py (working copy) >@@ -90,7 +90,10 @@ > > 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 @@ > 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 @@ > 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 @@ > 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 @@ > > 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 @@ > 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 @@ > 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 @@ > 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,38 +515,38 @@ > 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") >+ 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") > >- file.write(" characterClass->m_hasNonBMPCharacters = {};\n".format(("false", "true")[self.hasNonBMPCharacters])) >- file.write(" return characterClass;\n}\n\n") >+ dowrite(file, " characterClass->m_hasNonBMPCharacters = {};\n".format(("false", "true")[self.hasNonBMPCharacters])) >+ dowrite(file, " return characterClass;\n}\n\n") > > @classmethod > def dumpAll(cls, file): >@@ -543,21 +553,21 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > > propertyDataHFile = openOrExit(unicodeProertyDataHPath, "wb") > >- propertyDataHFile.write(header) >+ dowrite(propertyDataHFile, header) > > aliases.parsePropertyAliasesFile(propertyAliasesFile) > aliases.parsePropertyValueAliasesFile(propertyValueAliasesFile) >@@ -974,6 +984,6 @@ > binaryProperty.dump(propertyDataHFile) > scripts.dump(propertyDataHFile) > >- propertyDataHFile.write(footer) >+ dowrite(propertyDataHFile, footer) > > exit(0) >Index: Source/JavaScriptCore/Scripts/hasher.py >=================================================================== >--- Source/JavaScriptCore/Scripts/hasher.py (revision 234555) >+++ Source/JavaScriptCore/Scripts/hasher.py (working copy) >@@ -36,7 +36,7 @@ > hash = stringHashingStartValue > > strLength = len(str) >- characterPairs = strLength / 2 >+ characterPairs = int(strLength / 2) > remainder = strLength & 1 > > # Main loop >Index: Source/JavaScriptCore/Scripts/jsmin.py >=================================================================== >--- Source/JavaScriptCore/Scripts/jsmin.py (revision 234555) >+++ Source/JavaScriptCore/Scripts/jsmin.py (working copy) >@@ -79,10 +79,13 @@ > 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 @@ > 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 @@ > 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 @@ > 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,7 +220,7 @@ > 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 = [] > >@@ -224,7 +227,7 @@ > previous = next1 > next1 = next2 > >- if previous >= '!': >+ if str(previous) >= '!': > previous_non_space = previous > > if previous == '\\': >Index: Source/JavaScriptCore/Scripts/make-js-file-arrays.py >=================================================================== >--- Source/JavaScriptCore/Scripts/make-js-file-arrays.py (revision 234555) >+++ Source/JavaScriptCore/Scripts/make-js-file-arrays.py (working copy) >@@ -25,7 +25,11 @@ > 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 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 @@ > 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) > >Index: Source/JavaScriptCore/Scripts/wkbuiltins/__init__.py >=================================================================== >--- Source/JavaScriptCore/Scripts/wkbuiltins/__init__.py (revision 234555) >+++ Source/JavaScriptCore/Scripts/wkbuiltins/__init__.py (working copy) >@@ -1,3 +1,3 @@ > # Required for Python to search this directory for module files > >-from builtins import * >+from wkbuiltins import * >Index: Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_combined_header.py >=================================================================== >--- Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_combined_header.py (revision 234555) >+++ Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_combined_header.py (working copy) >@@ -158,7 +158,7 @@ > > 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 = [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 = { >Index: Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_combined_implementation.py >=================================================================== >Index: Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_internals_wrapper_header.py >=================================================================== >--- Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_internals_wrapper_header.py (revision 234555) >+++ Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_internals_wrapper_header.py (working copy) >@@ -36,7 +36,7 @@ > class BuiltinsInternalsWrapperHeaderGenerator(BuiltinsGenerator): > def __init__(self, model): > BuiltinsGenerator.__init__(self, model) >- self.internals = filter(lambda object: 'internal' in object.annotations, model.objects) >+ 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') >Index: Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_internals_wrapper_implementation.py >=================================================================== >--- Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_internals_wrapper_implementation.py (revision 234555) >+++ Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_internals_wrapper_implementation.py (working copy) >@@ -36,7 +36,7 @@ > class BuiltinsInternalsWrapperImplementationGenerator(BuiltinsGenerator): > def __init__(self, model): > BuiltinsGenerator.__init__(self, model) >- self.internals = filter(lambda object: 'internal' in object.annotations, model.objects) >+ 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') >Index: Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_separate_header.py >=================================================================== >Index: Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_separate_implementation.py >=================================================================== >Index: Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_wrapper_header.py >=================================================================== >Index: Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_wrapper_implementation.py >=================================================================== >Index: Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generator.py >=================================================================== >Index: Source/JavaScriptCore/Scripts/wkbuiltins/builtins_model.py >=================================================================== >--- Source/JavaScriptCore/Scripts/wkbuiltins/builtins_model.py (revision 234555) >+++ Source/JavaScriptCore/Scripts/wkbuiltins/builtins_model.py (working copy) >@@ -26,6 +26,7 @@ > import logging > import re > import os >+import sys > > from builtins_templates import BuiltinsGeneratorTemplates as Templates > >@@ -155,6 +156,8 @@ > > return interface > >+ def __lt__(self, other): >+ return self.function_name < other.function_name > > class BuiltinsCollection: > def __init__(self, framework_name): >@@ -210,7 +213,7 @@ > > result = [] > >- for owner, years in owner_to_years.items(): >+ for owner, years in list(owner_to_years.items()): > sorted_years = list(years) > sorted_years.sort() > result.append("%s %s" % (', '.join(sorted_years), owner)) >@@ -303,4 +306,4 @@ > functionBounds.append((start, end)) > > functionStrings = [text[start:end].strip() for (start, end) in functionBounds] >- return map(BuiltinFunction.fromString, functionStrings) >+ return list(map(BuiltinFunction.fromString, functionStrings)) >Index: Source/JavaScriptCore/Scripts/wkbuiltins/builtins_templates.py >=================================================================== >Index: Source/JavaScriptCore/Scripts/wkbuiltins/wkbuiltins.py >=================================================================== >Index: Source/JavaScriptCore/disassembler/udis86/ud_opcode.py >=================================================================== >--- Source/JavaScriptCore/disassembler/udis86/ud_opcode.py (revision 234555) >+++ Source/JavaScriptCore/disassembler/udis86/ud_opcode.py (working copy) >@@ -550,10 +550,10 @@ > 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) > > >Index: Source/JavaScriptCore/generate-bytecode-files >=================================================================== >--- Source/JavaScriptCore/generate-bytecode-files (revision 234555) >+++ Source/JavaScriptCore/generate-bytecode-files (working copy) >@@ -94,6 +94,12 @@ > 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 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 @@ > 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 @@ > bytecodeNum = 0 > for bytecode in section["bytecodes"]: > if not firstMacro: >- bytecodeHFile.write(" \\\n") >+ dowrite(bytecodeHFile, " \\\n") > > length = defaultLength > if "length" in bytecode: >@@ -256,16 +262,16 @@ > # 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: >@@ -272,16 +278,16 @@ > 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 = "" >@@ -288,7 +294,7 @@ > 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: >Index: Source/JavaScriptCore/inspector/scripts/codegen/__init__.py >=================================================================== >--- Source/JavaScriptCore/inspector/scripts/codegen/__init__.py (revision 234555) >+++ Source/JavaScriptCore/inspector/scripts/codegen/__init__.py (working copy) >@@ -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 * >Index: Source/JavaScriptCore/inspector/scripts/codegen/cpp_generator.py >=================================================================== >--- Source/JavaScriptCore/inspector/scripts/codegen/cpp_generator.py (revision 234555) >+++ Source/JavaScriptCore/inspector/scripts/codegen/cpp_generator.py (working copy) >@@ -28,8 +28,8 @@ > 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') > >Index: Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py >=================================================================== >--- Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py (revision 234555) >+++ Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py (working copy) >@@ -30,8 +30,8 @@ > 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 @@ > 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) > >Index: Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py >=================================================================== >--- Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py (revision 234555) >+++ Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py (working copy) >@@ -30,10 +30,10 @@ > 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 @@ > 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 @@ > 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 @@ > 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, >Index: Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py >=================================================================== >--- Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py (revision 234555) >+++ Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py (working copy) >@@ -29,10 +29,10 @@ > 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 @@ > 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 @@ > 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) > >Index: Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py >=================================================================== >--- Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py (revision 234555) >+++ Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py (working copy) >@@ -30,10 +30,10 @@ > 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 @@ > 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 @@ > 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) > >Index: Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py >=================================================================== >--- Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py (revision 234555) >+++ Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py (working copy) >@@ -29,10 +29,10 @@ > 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 @@ > 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 @@ > 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) > >Index: Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_header.py >=================================================================== >--- Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_header.py (revision 234555) >+++ Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_header.py (working copy) >@@ -31,10 +31,10 @@ > 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 @@ > 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()) > sections.extend(self._generate_declarations_for_enum_conversion_methods()) > sections.append('} // namespace Protocol') >@@ -87,8 +87,8 @@ > > 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')) > >@@ -113,8 +113,8 @@ > """ % '\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 '' >@@ -125,8 +125,8 @@ > > 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 '' > >@@ -186,7 +186,7 @@ > 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 '' > >@@ -200,9 +200,9 @@ > 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 = [] >@@ -261,7 +261,7 @@ > 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): >@@ -275,7 +275,7 @@ > > 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 {') >@@ -343,7 +343,7 @@ > > for domain in self.domains_to_generate(): > 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: >@@ -392,8 +392,8 @@ > for domain in self.domains_to_generate(): > 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 > >Index: Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py >=================================================================== >--- Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py (revision 234555) >+++ Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py (working copy) >@@ -30,10 +30,10 @@ > 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 @@ > 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 @@ > > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 = [] > >Index: Source/JavaScriptCore/inspector/scripts/codegen/generate_js_backend_commands.py >=================================================================== >--- Source/JavaScriptCore/inspector/scripts/codegen/generate_js_backend_commands.py (revision 234555) >+++ Source/JavaScriptCore/inspector/scripts/codegen/generate_js_backend_commands.py (working copy) >@@ -30,9 +30,9 @@ > 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 @@ > > 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 @@ > 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) > >Index: Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py >=================================================================== >--- Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py (revision 234555) >+++ Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py (working copy) >@@ -30,11 +30,11 @@ > 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 @@ > 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 @@ > 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) > >Index: Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py >=================================================================== >--- Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py (revision 234555) >+++ Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py (working copy) >@@ -30,11 +30,11 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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)) >Index: Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_configuration_header.py >=================================================================== >--- Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_configuration_header.py (revision 234555) >+++ Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_configuration_header.py (working copy) >@@ -29,9 +29,9 @@ > 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') > >Index: Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_configuration_implementation.py >=================================================================== >--- Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_configuration_implementation.py (revision 234555) >+++ Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_configuration_implementation.py (working copy) >@@ -29,9 +29,9 @@ > 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') > >Index: Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py >=================================================================== >--- Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py (revision 234555) >+++ Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py (working copy) >@@ -29,10 +29,10 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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)) >Index: Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_header.py >=================================================================== >--- Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_header.py (revision 234555) >+++ Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_header.py (working copy) >@@ -29,10 +29,10 @@ > 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 @@ > } > > 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 @@ > 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 @@ > 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: >Index: Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_internal_header.py >=================================================================== >--- Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_internal_header.py (revision 234555) >+++ Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_internal_header.py (working copy) >@@ -29,9 +29,9 @@ > 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 @@ > '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) > >Index: Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_header.py >=================================================================== >--- Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_header.py (revision 234555) >+++ Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_header.py (working copy) >@@ -29,10 +29,10 @@ > 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 @@ > 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 @@ > 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) > >Index: Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_implementation.py >=================================================================== >--- Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_implementation.py (revision 234555) >+++ Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_implementation.py (working copy) >@@ -28,10 +28,10 @@ > 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 @@ > 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 = [ >Index: Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_types_implementation.py >=================================================================== >--- Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_types_implementation.py (revision 234555) >+++ Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_types_implementation.py (working copy) >@@ -29,10 +29,10 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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) >Index: Source/JavaScriptCore/inspector/scripts/codegen/generator.py >=================================================================== >--- Source/JavaScriptCore/inspector/scripts/codegen/generator.py (revision 234555) >+++ Source/JavaScriptCore/inspector/scripts/codegen/generator.py (working copy) >@@ -29,8 +29,8 @@ > 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 @@ > > # 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 @@ > 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 @@ > # 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 @@ > 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 @@ > 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 >Index: Source/JavaScriptCore/inspector/scripts/codegen/models.py >=================================================================== >--- Source/JavaScriptCore/inspector/scripts/codegen/models.py (revision 234555) >+++ Source/JavaScriptCore/inspector/scripts/codegen/models.py (working copy) >@@ -35,7 +35,7 @@ > > > 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 = { >Index: Source/JavaScriptCore/inspector/scripts/codegen/objc_generator.py >=================================================================== >--- Source/JavaScriptCore/inspector/scripts/codegen/objc_generator.py (revision 234555) >+++ Source/JavaScriptCore/inspector/scripts/codegen/objc_generator.py (working copy) >@@ -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 @@ > '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: >Index: Source/JavaScriptCore/wasm/generateWasm.py >=================================================================== >--- Source/JavaScriptCore/wasm/generateWasm.py (revision 234555) >+++ Source/JavaScriptCore/wasm/generateWasm.py (working copy) >@@ -71,7 +71,7 @@ > # 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) > >Index: Source/JavaScriptCore/yarr/generateYarrCanonicalizeUnicode >=================================================================== >--- Source/JavaScriptCore/yarr/generateYarrCanonicalizeUnicode (revision 234555) >+++ Source/JavaScriptCore/yarr/generateYarrCanonicalizeUnicode (working copy) >@@ -31,7 +31,6 @@ > import os > import re > import sys >-from sets import Set > > header = """/* > * Copyright (C) 2016 Apple Inc. All rights reserved. >@@ -78,11 +77,21 @@ > 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 @@ > 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 @@ > 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 @@ > canonicalize = Canonicalize() > canonicalize.readCaseFolding(caseFoldingTxtFile) > >- canonicalizeHFile.write(header); >+ dowrite(canonicalizeHFile, header) > canonicalize.createTables(canonicalizeHFile) >- canonicalizeHFile.write(footer); >+ dowrite(canonicalizeHFile, footer) > > caseFoldingTxtFile.close() > canonicalizeHFile.close() >Index: Source/WebCore/CMakeLists.txt >=================================================================== >--- Source/WebCore/CMakeLists.txt (revision 234555) >+++ Source/WebCore/CMakeLists.txt (working copy) >@@ -1849,7 +1849,7 @@ > ) > > 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 >Index: Source/WebCore/platform/network/create-http-header-name-table >=================================================================== >--- Source/WebCore/platform/network/create-http-header-name-table (revision 234555) >+++ Source/WebCore/platform/network/create-http-header-name-table (working copy) >@@ -42,7 +42,7 @@ > 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 >Index: Source/WebInspectorUI/Scripts/copy-user-interface-resources.pl >=================================================================== >--- Source/WebInspectorUI/Scripts/copy-user-interface-resources.pl (revision 234555) >+++ Source/WebInspectorUI/Scripts/copy-user-interface-resources.pl (working copy) >@@ -176,6 +176,8 @@ > 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: $!"; > >Index: Source/cmake/WebKitCommon.cmake >=================================================================== >--- Source/cmake/WebKitCommon.cmake (revision 234555) >+++ Source/cmake/WebKitCommon.cmake (working copy) >@@ -21,9 +21,6 @@ > 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
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
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 156674
:
335141
|
346638
|
347950
|
348154
|
350121
|
350303
|
350816