Build tools should work when the /usr/bin/python is python3
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Sep 2018 16:20:05 +0000 (16:20 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Sep 2018 16:20:05 +0000 (16:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=156674

Patch by Mike Gorse <mgorse@suse.com> on 2018-09-21
Reviewed by Michael Catanzaro.

.:

* Source/cmake/WebKitCommon.cmake: Allow python 3.

Source/JavaScriptCore:

* Scripts/cssmin.py:
* Scripts/generate-js-builtins.py:
(do_open):
(generate_bindings_for_builtins_files):
* Scripts/generateIntlCanonicalizeLanguage.py:
* Scripts/jsmin.py:
(JavascriptMinify.minify.write):
(JavascriptMinify):
(JavascriptMinify.minify):
* Scripts/make-js-file-arrays.py:
(chunk):
(main):
* Scripts/wkbuiltins/__init__.py:
* Scripts/wkbuiltins/builtins_generate_combined_header.py:
(generate_section_for_global_private_code_name_macro):
* Scripts/wkbuiltins/builtins_generate_internals_wrapper_header.py:
(BuiltinsInternalsWrapperHeaderGenerator.__init__):
* Scripts/wkbuiltins/builtins_generate_internals_wrapper_implementation.py:
(BuiltinsInternalsWrapperImplementationGenerator.__init__):
* Scripts/wkbuiltins/builtins_model.py:
(BuiltinFunction.__lt__):
(BuiltinsCollection.copyrights):
(BuiltinsCollection._parse_functions):
* disassembler/udis86/ud_opcode.py:
(UdOpcodeTables.pprint.printWalk):
* generate-bytecode-files:
* inspector/scripts/codegen/__init__.py:
* inspector/scripts/codegen/cpp_generator.py:
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator.generate_output):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.domains_to_generate):
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declarations_for_domain):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator.domains_to_generate):
(CppBackendDispatcherImplementationGenerator.generate_output):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator.domains_to_generate):
(CppFrontendDispatcherHeaderGenerator.generate_output):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator.domains_to_generate):
(CppFrontendDispatcherImplementationGenerator.generate_output):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator.generate_output):
(CppProtocolTypesHeaderGenerator._generate_forward_declarations):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator.generate_output):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_enum_mapping_and_conversion_methods):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_builders_for_domain):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_object_declaration):
* inspector/scripts/codegen/generate_js_backend_commands.py:
(JSBackendCommandsGenerator.should_generate_domain):
(JSBackendCommandsGenerator.domains_to_generate):
(JSBackendCommandsGenerator.generate_output):
(JSBackendCommandsGenerator.generate_domain):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator.domains_to_generate):
(ObjCBackendDispatcherHeaderGenerator.generate_output):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator.domains_to_generate):
(ObjCBackendDispatcherImplementationGenerator.generate_output):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
* inspector/scripts/codegen/generate_objc_configuration_header.py:
* inspector/scripts/codegen/generate_objc_configuration_implementation.py:
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator.domains_to_generate):
(ObjCFrontendDispatcherImplementationGenerator.generate_output):
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
* inspector/scripts/codegen/generate_objc_header.py:
(ObjCHeaderGenerator.generate_output):
(ObjCHeaderGenerator._generate_type_interface):
* inspector/scripts/codegen/generate_objc_internal_header.py:
(ObjCInternalHeaderGenerator.generate_output):
* inspector/scripts/codegen/generate_objc_protocol_type_conversions_header.py:
(ObjCProtocolTypeConversionsHeaderGenerator.domains_to_generate):
(ObjCProtocolTypeConversionsHeaderGenerator.generate_output):
* inspector/scripts/codegen/generate_objc_protocol_type_conversions_implementation.py:
(ObjCProtocolTypeConversionsImplementationGenerator.domains_to_generate):
* inspector/scripts/codegen/generate_objc_protocol_types_implementation.py:
(ObjCProtocolTypesImplementationGenerator.domains_to_generate):
(ObjCProtocolTypesImplementationGenerator.generate_output):
(ObjCProtocolTypesImplementationGenerator.generate_type_implementation):
(ObjCProtocolTypesImplementationGenerator._generate_init_method_for_required_members):
* inspector/scripts/codegen/generator.py:
(Generator.non_supplemental_domains):
(Generator.open_fields):
(Generator.calculate_types_requiring_shape_assertions):
(Generator._traverse_and_assign_enum_values):
(Generator.stylized_name_for_enum_value):
* inspector/scripts/codegen/models.py:
(find_duplicates):
* inspector/scripts/codegen/objc_generator.py:
* wasm/generateWasm.py:
(opcodeIterator):
* yarr/generateYarrCanonicalizeUnicode:
* yarr/generateYarrUnicodePropertyTables.py:
* yarr/hasher.py:
(stringHash):

Source/WebCore:

No new tests (no behavior change).

* platform/network/create-http-header-name-table: remove xreadlines.

Source/WebInspectorUI:

* Scripts/copy-user-interface-resources.pl: Use $PYTHON if set
in the environment.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236321 268f45cc-cd09-0410-ab3c-d52691b4dbfc

46 files changed:
ChangeLog
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/Scripts/generate-js-builtins.py
Source/JavaScriptCore/Scripts/generateIntlCanonicalizeLanguage.py
Source/JavaScriptCore/Scripts/jsmin.py
Source/JavaScriptCore/Scripts/make-js-file-arrays.py
Source/JavaScriptCore/Scripts/wkbuiltins/__init__.py
Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_combined_header.py
Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_internals_wrapper_header.py
Source/JavaScriptCore/Scripts/wkbuiltins/builtins_generate_internals_wrapper_implementation.py
Source/JavaScriptCore/Scripts/wkbuiltins/builtins_model.py
Source/JavaScriptCore/disassembler/udis86/ud_opcode.py
Source/JavaScriptCore/generate-bytecode-files
Source/JavaScriptCore/inspector/scripts/codegen/__init__.py
Source/JavaScriptCore/inspector/scripts/codegen/cpp_generator.py
Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py
Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py
Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py
Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py
Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py
Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_header.py
Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py
Source/JavaScriptCore/inspector/scripts/codegen/generate_js_backend_commands.py
Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py
Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py
Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_configuration_header.py
Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_configuration_implementation.py
Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py
Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_header.py
Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_internal_header.py
Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_header.py
Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_type_conversions_implementation.py
Source/JavaScriptCore/inspector/scripts/codegen/generate_objc_protocol_types_implementation.py
Source/JavaScriptCore/inspector/scripts/codegen/generator.py
Source/JavaScriptCore/inspector/scripts/codegen/models.py
Source/JavaScriptCore/inspector/scripts/codegen/objc_generator.py
Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py
Source/JavaScriptCore/wasm/generateWasm.py
Source/JavaScriptCore/yarr/generateYarrCanonicalizeUnicode
Source/JavaScriptCore/yarr/generateYarrUnicodePropertyTables.py
Source/JavaScriptCore/yarr/hasher.py
Source/WebCore/ChangeLog
Source/WebCore/platform/network/create-http-header-name-table
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Scripts/copy-user-interface-resources.pl
Source/cmake/WebKitCommon.cmake

index 1f9d9f4..532b326 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2018-09-21  Mike Gorse  <mgorse@suse.com>
+
+        Build tools should work when the /usr/bin/python is python3
+        https://bugs.webkit.org/show_bug.cgi?id=156674
+
+        Reviewed by Michael Catanzaro.
+
+        * Source/cmake/WebKitCommon.cmake: Allow python 3.
+
 2018-09-20  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Unreviewed. Update GTK+ library versions after r235362.
index ab02f4a..7c28919 100644 (file)
@@ -1,3 +1,112 @@
+2018-09-21  Mike Gorse  <mgorse@suse.com>
+
+        Build tools should work when the /usr/bin/python is python3
+        https://bugs.webkit.org/show_bug.cgi?id=156674
+
+        Reviewed by Michael Catanzaro.
+
+        * Scripts/cssmin.py:
+        * Scripts/generate-js-builtins.py:
+        (do_open):
+        (generate_bindings_for_builtins_files):
+        * Scripts/generateIntlCanonicalizeLanguage.py:
+        * Scripts/jsmin.py:
+        (JavascriptMinify.minify.write):
+        (JavascriptMinify):
+        (JavascriptMinify.minify):
+        * Scripts/make-js-file-arrays.py:
+        (chunk):
+        (main):
+        * Scripts/wkbuiltins/__init__.py:
+        * Scripts/wkbuiltins/builtins_generate_combined_header.py:
+        (generate_section_for_global_private_code_name_macro):
+        * Scripts/wkbuiltins/builtins_generate_internals_wrapper_header.py:
+        (BuiltinsInternalsWrapperHeaderGenerator.__init__):
+        * Scripts/wkbuiltins/builtins_generate_internals_wrapper_implementation.py:
+        (BuiltinsInternalsWrapperImplementationGenerator.__init__):
+        * Scripts/wkbuiltins/builtins_model.py:
+        (BuiltinFunction.__lt__):
+        (BuiltinsCollection.copyrights):
+        (BuiltinsCollection._parse_functions):
+        * disassembler/udis86/ud_opcode.py:
+        (UdOpcodeTables.pprint.printWalk):
+        * generate-bytecode-files:
+        * inspector/scripts/codegen/__init__.py:
+        * inspector/scripts/codegen/cpp_generator.py:
+        * inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
+        (CppAlternateBackendDispatcherHeaderGenerator.generate_output):
+        * inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
+        (CppBackendDispatcherHeaderGenerator.domains_to_generate):
+        (CppBackendDispatcherHeaderGenerator.generate_output):
+        (CppBackendDispatcherHeaderGenerator._generate_dispatcher_declarations_for_domain):
+        * inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
+        (CppBackendDispatcherImplementationGenerator.domains_to_generate):
+        (CppBackendDispatcherImplementationGenerator.generate_output):
+        * inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
+        (CppFrontendDispatcherHeaderGenerator.domains_to_generate):
+        (CppFrontendDispatcherHeaderGenerator.generate_output):
+        * inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
+        (CppFrontendDispatcherImplementationGenerator.domains_to_generate):
+        (CppFrontendDispatcherImplementationGenerator.generate_output):
+        * inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
+        (CppProtocolTypesHeaderGenerator.generate_output):
+        (CppProtocolTypesHeaderGenerator._generate_forward_declarations):
+        * inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
+        (CppProtocolTypesImplementationGenerator.generate_output):
+        (CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
+        (CppProtocolTypesImplementationGenerator._generate_enum_mapping_and_conversion_methods):
+        (CppProtocolTypesImplementationGenerator._generate_open_field_names):
+        (CppProtocolTypesImplementationGenerator._generate_builders_for_domain):
+        (CppProtocolTypesImplementationGenerator._generate_assertion_for_object_declaration):
+        * inspector/scripts/codegen/generate_js_backend_commands.py:
+        (JSBackendCommandsGenerator.should_generate_domain):
+        (JSBackendCommandsGenerator.domains_to_generate):
+        (JSBackendCommandsGenerator.generate_output):
+        (JSBackendCommandsGenerator.generate_domain):
+        * inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
+        (ObjCBackendDispatcherHeaderGenerator.domains_to_generate):
+        (ObjCBackendDispatcherHeaderGenerator.generate_output):
+        * inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
+        (ObjCBackendDispatcherImplementationGenerator.domains_to_generate):
+        (ObjCBackendDispatcherImplementationGenerator.generate_output):
+        (ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
+        * inspector/scripts/codegen/generate_objc_configuration_header.py:
+        * inspector/scripts/codegen/generate_objc_configuration_implementation.py:
+        * inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
+        (ObjCFrontendDispatcherImplementationGenerator.domains_to_generate):
+        (ObjCFrontendDispatcherImplementationGenerator.generate_output):
+        (ObjCFrontendDispatcherImplementationGenerator._generate_event):
+        * inspector/scripts/codegen/generate_objc_header.py:
+        (ObjCHeaderGenerator.generate_output):
+        (ObjCHeaderGenerator._generate_type_interface):
+        * inspector/scripts/codegen/generate_objc_internal_header.py:
+        (ObjCInternalHeaderGenerator.generate_output):
+        * inspector/scripts/codegen/generate_objc_protocol_type_conversions_header.py:
+        (ObjCProtocolTypeConversionsHeaderGenerator.domains_to_generate):
+        (ObjCProtocolTypeConversionsHeaderGenerator.generate_output):
+        * inspector/scripts/codegen/generate_objc_protocol_type_conversions_implementation.py:
+        (ObjCProtocolTypeConversionsImplementationGenerator.domains_to_generate):
+        * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py:
+        (ObjCProtocolTypesImplementationGenerator.domains_to_generate):
+        (ObjCProtocolTypesImplementationGenerator.generate_output):
+        (ObjCProtocolTypesImplementationGenerator.generate_type_implementation):
+        (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_required_members):
+        * inspector/scripts/codegen/generator.py:
+        (Generator.non_supplemental_domains):
+        (Generator.open_fields):
+        (Generator.calculate_types_requiring_shape_assertions):
+        (Generator._traverse_and_assign_enum_values):
+        (Generator.stylized_name_for_enum_value):
+        * inspector/scripts/codegen/models.py:
+        (find_duplicates):
+        * inspector/scripts/codegen/objc_generator.py:
+        * wasm/generateWasm.py:
+        (opcodeIterator):
+        * yarr/generateYarrCanonicalizeUnicode:
+        * yarr/generateYarrUnicodePropertyTables.py:
+        * yarr/hasher.py:
+        (stringHash):
+
 2018-09-21  Tomas Popela  <tpopela@redhat.com>
 
         [ARM] Build broken on armv7hl after r235517
index 48a9bb0..dde7224 100644 (file)
@@ -31,6 +31,7 @@ import fnmatch
 import logging
 import optparse
 import os
+import sys
 
 logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.ERROR)
 log = logging.getLogger('global')
@@ -46,6 +47,12 @@ def concatenated_output_filename(builtins_files, framework_name, generate_only_w
     return os.path.basename(builtins_files[0]) + '-result'
 
 
+def do_open(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 +66,7 @@ def generate_bindings_for_builtins_files(builtins_files=[],
     model = BuiltinsCollection(framework_name=framework_name)
 
     for filepath in builtins_files:
-        with open(filepath, "r") as file:
+        with do_open(filepath, "r") as file:
             file_text = file.read()
             file_name = os.path.basename(filepath)
 
@@ -146,7 +153,7 @@ if __name__ == '__main__':
         for filepath in os.listdir(arg_options.input_directory):
             input_filepaths.append(os.path.join(arg_options.input_directory, filepath))
 
-    input_filepaths = sorted(filter(lambda name: fnmatch.fnmatch(name, '*.js'), input_filepaths))
+    input_filepaths = sorted([name for name in input_filepaths if fnmatch.fnmatch(name, '*.js')])
 
     options = {
         'output_path': arg_options.output_directory,
@@ -159,7 +166,7 @@ if __name__ == '__main__':
 
     log.debug("Generating code for builtins.")
     log.debug("Parsed options:")
-    for option, value in options.items():
+    for option, value in list(options.items()):
         log.debug("    %s: %s" % (option, value))
     log.debug("")
     log.debug("Input files:")
index 69f3be8..949b0b6 100644 (file)
@@ -189,7 +189,7 @@ if __name__ == "__main__":
     intlCanonHPath = args[1]
 
     registryFile = openOrExit(registryPath, "r")
-    intlCanonHFile = openOrExit(intlCanonHPath, "wb")
+    intlCanonHFile = openOrExit(intlCanonHPath, "w")
 
     intlCanonHFile.write(header)
 
index 372418b..fc647c7 100644 (file)
@@ -79,10 +79,13 @@ class JavascriptMinify(object):
         def write(char):
             # all of this is to support literal regular expressions.
             # sigh
-            if char in 'return':
+            if str(char) in 'return':
                 self.return_buf += char
                 self.is_return = self.return_buf == 'return'
-            self.outs.write(char)
+            if sys.version_info.major == 2:
+                self.outs.write(char)
+            else:
+                self.outs.write(str(char))
             if self.is_return:
                 self.return_buf = ''
 
@@ -118,8 +121,8 @@ class JavascriptMinify(object):
                 write(previous)
         elif not previous:
             return
-        elif previous >= '!':
-            if previous in "'\"":
+        elif str(previous) >= "!":
+            if str(previous) in "'\"":
                 in_quote = previous
             write(previous)
             previous_non_space = previous
@@ -166,7 +169,7 @@ class JavascriptMinify(object):
                     if numslashes % 2 == 0:
                         in_quote = ''
                         write(''.join(quote_buf))
-            elif next1 in '\r\n':
+            elif str(next1) in '\r\n':
                 if previous_non_space in newlineend_strings \
                     or previous_non_space > '~':
                     while 1:
@@ -179,7 +182,7 @@ class JavascriptMinify(object):
                                 or next2 > '~' or next2 == '/':
                                 do_newline = True
                             break
-            elif next1 < '!' and not in_re:
+            elif str(next1) < '!' and not in_re:
                 if (previous_non_space in space_strings \
                     or previous_non_space > '~') \
                     and (next2 in space_strings or next2 > '~'):
@@ -217,14 +220,14 @@ class JavascriptMinify(object):
                     do_newline = False
 
                 write(next1)
-                if not in_re and next1 in "'\"`":
+                if not in_re and str(next1) in "'\"`":
                     in_quote = next1
                     quote_buf = []
 
             previous = next1
             next1 = next2
 
-            if previous >= '!':
+            if str(previous) >= '!':
                 previous_non_space = previous
 
             if previous == '\\':
index c37cc12..8624bfe 100755 (executable)
@@ -25,7 +25,11 @@ from __future__ import print_function
 import io
 import os
 from optparse import OptionParser
-from StringIO import StringIO
+import sys
+if sys.version_info.major == 2:
+    from StringIO import StringIO
+else:
+    from io import StringIO
 from jsmin import JavascriptMinify
 
 
@@ -37,7 +41,7 @@ def stringifyCodepoint(code):
 
 
 def chunk(list, chunkSize):
-    for i in xrange(0, len(list), chunkSize):
+    for i in range(0, len(list), chunkSize):
         yield list[i:i + chunkSize]
 
 
@@ -85,7 +89,7 @@ def main():
         print('extern const char {0:s}JavaScript[{1:d}];'.format(variableName, size), file=headerFile)
         print('const char {0:s}JavaScript[{1:d}] = {{'.format(variableName, size), file=sourceFile)
 
-        codepoints = map(ord, characters)
+        codepoints = list(map(ord, characters))
         for codepointChunk in chunk(codepoints, 16):
             print('    {0:s},'.format(','.join(map(stringifyCodepoint, codepointChunk))), file=sourceFile)
 
index d6f9329..ffa849e 100644 (file)
@@ -1,3 +1,3 @@
 # Required for Python to search this directory for module files
 
-from wkbuiltins import *
+from .wkbuiltins import *
index cde357c..eac6948 100644 (file)
@@ -158,7 +158,7 @@ extern const JSC::ConstructAbility s_%(codeName)sConstructAbility;""" % function
 
         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 0b913dc..8025612 100644 (file)
@@ -36,7 +36,7 @@ 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)
+        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 52b4b20..3982506 100644 (file)
@@ -36,7 +36,7 @@ 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)
+        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 0519c5e..1f49a55 100644 (file)
@@ -155,6 +155,9 @@ class BuiltinFunction:
 
         return interface
 
+    def __lt__(self, other):
+        return self.function_name < other.function_name
+
 
 class BuiltinsCollection:
     def __init__(self, framework_name):
@@ -210,7 +213,7 @@ class BuiltinsCollection:
 
         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 @@ class BuiltinsCollection:
             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 fe1833d..30c9f43 100644 (file)
@@ -550,10 +550,10 @@ class UdOpcodeTables(object):
             entries = tbl.entries()
             for k, e in entries:
                 if isinstance(e, UdOpcodeTable):
-                    self.log("%s    |-<%02x> %s" % (indent, k, e))
+                    self.log("%s    |-<%02x> %s" % (indent, int(k), e))
                     printWalk(e, indent + "    |")
                 elif isinstance(e, UdInsnDef):
-                    self.log("%s    |-<%02x> %s" % (indent, k, e))
+                    self.log("%s    |-<%02x> %s" % (indent, int(k), e))
         printWalk(self.root)
 
 
index fa25fd2..7838ed3 100644 (file)
@@ -126,7 +126,7 @@ def writeStruct(bytecodeHFile, bytecode):
 
     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")
@@ -134,7 +134,7 @@ def writeStruct(bytecodeHFile, bytecode):
 
     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")
 
@@ -206,13 +206,13 @@ if __name__ == "__main__":
         exit(0)
 
     if bytecodeHFilename:
-        bytecodeHFile = openOrExit(bytecodeHFilename, "wb")
+        bytecodeHFile = openOrExit(bytecodeHFilename, "w")
 
     if bytecodeStructsHFilename:
-        bytecodeStructsHFile = openOrExit(bytecodeStructsHFilename, "wb")
+        bytecodeStructsHFile = openOrExit(bytecodeStructsHFilename, "w")
 
     if initASMFileName:
-        initBytecodesFile = openOrExit(initASMFileName, "wb")
+        initBytecodesFile = openOrExit(initASMFileName, "w")
 
     try:
         bytecodeSections = json.load(bytecodeFile, encoding = "utf-8")
index 37dbe94..1a4ac69 100644 (file)
@@ -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 5f2e9c8..4e98705 100644 (file)
@@ -28,8 +28,12 @@ import logging
 import os.path
 import re
 
-from generator import ucfirst, Generator
-from models import PrimitiveType, ObjectType, ArrayType, EnumType, AliasedType, Frameworks
+try:
+    from .generator import ucfirst, Generator
+    from .models import PrimitiveType, ObjectType, ArrayType, EnumType, AliasedType, Frameworks
+except ValueError:
+    from generator import ucfirst, Generator
+    from models import PrimitiveType, ObjectType, ArrayType, EnumType, AliasedType, Frameworks
 
 log = logging.getLogger('global')
 
index f6bf86d..e627880 100755 (executable)
@@ -30,8 +30,12 @@ import string
 import re
 from string import Template
 
-from cpp_generator import CppGenerator
-from cpp_generator_templates import CppGeneratorTemplates as CppTemplates
+try:
+    from .cpp_generator import CppGenerator
+    from .cpp_generator_templates import CppGeneratorTemplates as CppTemplates
+except ValueError:
+    from cpp_generator import CppGenerator
+    from cpp_generator_templates import CppGeneratorTemplates as CppTemplates
 
 log = logging.getLogger('global')
 
@@ -52,7 +56,7 @@ class CppAlternateBackendDispatcherHeaderGenerator(CppGenerator):
         sections = []
         sections.append(self.generate_license())
         sections.append(Template(CppTemplates.AlternateDispatchersHeaderPrelude).substitute(None, **template_args))
-        sections.append('\n'.join(filter(None, map(self._generate_handler_declarations_for_domain, domains))))
+        sections.append('\n'.join([_f for _f in map(self._generate_handler_declarations_for_domain, domains) if _f]))
         sections.append(Template(CppTemplates.AlternateDispatchersHeaderPostlude).substitute(None, **template_args))
         return '\n\n'.join(sections)
 
index 0769c8a..e3fe4e1 100755 (executable)
@@ -30,10 +30,16 @@ import re
 import string
 from string import Template
 
-from cpp_generator import CppGenerator
-from cpp_generator_templates import CppGeneratorTemplates as CppTemplates
-from generator import Generator, ucfirst
-from models import EnumType
+try:
+    from .cpp_generator import CppGenerator
+    from .cpp_generator_templates import CppGeneratorTemplates as CppTemplates
+    from .generator import Generator, ucfirst
+    from .models import EnumType
+except ValueError:
+    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 +52,7 @@ class CppBackendDispatcherHeaderGenerator(CppGenerator):
         return "%sBackendDispatchers.h" % self.protocol_name()
 
     def domains_to_generate(self):
-        return filter(lambda domain: len(self.commands_for_domain(domain)) > 0, Generator.domains_to_generate(self))
+        return [domain for domain in Generator.domains_to_generate(self) if len(self.commands_for_domain(domain)) > 0]
 
     def generate_output(self):
         typedefs = [('String', 'ErrorString')]
@@ -62,8 +68,8 @@ class CppBackendDispatcherHeaderGenerator(CppGenerator):
         sections.append(Template(CppTemplates.HeaderPrelude).substitute(None, **header_args))
         if self.model().framework.setting('alternate_dispatchers', False):
             sections.append(self._generate_alternate_handler_forward_declarations_for_domains(domains))
-        sections.extend(map(self._generate_handler_declarations_for_domain, domains))
-        sections.extend(map(self._generate_dispatcher_declarations_for_domain, domains))
+        sections.extend(list(map(self._generate_handler_declarations_for_domain, domains)))
+        sections.extend(list(map(self._generate_dispatcher_declarations_for_domain, domains)))
         sections.append(Template(CppTemplates.HeaderPostlude).substitute(None, **header_args))
         return "\n\n".join(sections)
 
@@ -198,7 +204,7 @@ class CppBackendDispatcherHeaderGenerator(CppGenerator):
         commands = self.commands_for_domain(domain)
         if len(commands) > 0:
             declarations.append('private:')
-        declarations.extend(map(self._generate_dispatcher_declaration_for_command, commands))
+        declarations.extend(list(map(self._generate_dispatcher_declaration_for_command, commands)))
 
         declaration_args = {
             'domainName': domain.domain_name,
index c558ed4..e20aaf3 100755 (executable)
@@ -29,10 +29,16 @@ import logging
 import string
 from string import Template
 
-from cpp_generator import CppGenerator
-from cpp_generator_templates import CppGeneratorTemplates as CppTemplates
-from generator import Generator, ucfirst
-from models import ObjectType, ArrayType
+try:
+    from .cpp_generator import CppGenerator
+    from .cpp_generator_templates import CppGeneratorTemplates as CppTemplates
+    from .generator import Generator, ucfirst
+    from .models import ObjectType, ArrayType
+except ValueError:
+    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 +51,7 @@ class CppBackendDispatcherImplementationGenerator(CppGenerator):
         return "%sBackendDispatchers.cpp" % self.protocol_name()
 
     def domains_to_generate(self):
-        return filter(lambda domain: len(self.commands_for_domain(domain)) > 0, Generator.domains_to_generate(self))
+        return [domain for domain in Generator.domains_to_generate(self) if len(self.commands_for_domain(domain)) > 0]
 
     def generate_output(self):
         secondary_includes = self._generate_secondary_header_includes()
@@ -65,7 +71,7 @@ class CppBackendDispatcherImplementationGenerator(CppGenerator):
         sections.append(self.generate_license())
         sections.append(Template(CppTemplates.ImplementationPrelude).substitute(None, **header_args))
         sections.append("\n".join(map(self._generate_handler_class_destructor_for_domain, self.domains_to_generate())))
-        sections.extend(map(self._generate_dispatcher_implementations_for_domain, self.domains_to_generate()))
+        sections.extend(list(map(self._generate_dispatcher_implementations_for_domain, self.domains_to_generate())))
         sections.append(Template(CppTemplates.ImplementationPostlude).substitute(None, **header_args))
         return "\n\n".join(sections)
 
index 59bd766..5cf7478 100755 (executable)
@@ -30,10 +30,16 @@ import re
 import string
 from string import Template
 
-from cpp_generator import CppGenerator
-from cpp_generator_templates import CppGeneratorTemplates as CppTemplates
-from generator import Generator, ucfirst
-from models import EnumType
+try:
+    from .cpp_generator import CppGenerator
+    from .cpp_generator_templates import CppGeneratorTemplates as CppTemplates
+    from .generator import Generator, ucfirst
+    from .models import EnumType
+except ValueError:
+    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 +52,7 @@ class CppFrontendDispatcherHeaderGenerator(CppGenerator):
         return "%sFrontendDispatchers.h" % self.protocol_name()
 
     def domains_to_generate(self):
-        return filter(lambda domain: len(self.events_for_domain(domain)) > 0, Generator.domains_to_generate(self))
+        return [domain for domain in Generator.domains_to_generate(self) if len(self.events_for_domain(domain)) > 0]
 
     def generate_output(self):
         header_args = {
@@ -57,7 +63,7 @@ class CppFrontendDispatcherHeaderGenerator(CppGenerator):
         sections = []
         sections.append(self.generate_license())
         sections.append(Template(CppTemplates.HeaderPrelude).substitute(None, **header_args))
-        sections.extend(map(self._generate_dispatcher_declarations_for_domain, self.domains_to_generate()))
+        sections.extend(list(map(self._generate_dispatcher_declarations_for_domain, self.domains_to_generate())))
         sections.append(Template(CppTemplates.HeaderPostlude).substitute(None, **header_args))
         return "\n\n".join(sections)
 
index b6965f5..904d227 100755 (executable)
@@ -29,10 +29,16 @@ import logging
 import string
 from string import Template
 
-from cpp_generator import CppGenerator
-from cpp_generator_templates import CppGeneratorTemplates as CppTemplates
-from generator import Generator, ucfirst
-from models import ObjectType, ArrayType
+try:
+    from .cpp_generator import CppGenerator
+    from .cpp_generator_templates import CppGeneratorTemplates as CppTemplates
+    from .generator import Generator, ucfirst
+    from .models import ObjectType, ArrayType
+except:
+    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 +51,7 @@ class CppFrontendDispatcherImplementationGenerator(CppGenerator):
         return "%sFrontendDispatchers.cpp" % self.protocol_name()
 
     def domains_to_generate(self):
-        return filter(lambda domain: len(self.events_for_domain(domain)) > 0, Generator.domains_to_generate(self))
+        return [domain for domain in Generator.domains_to_generate(self) if len(self.events_for_domain(domain)) > 0]
 
     def generate_output(self):
         header_args = {
@@ -56,7 +62,7 @@ class CppFrontendDispatcherImplementationGenerator(CppGenerator):
         sections = []
         sections.append(self.generate_license())
         sections.append(Template(CppTemplates.ImplementationPrelude).substitute(None, **header_args))
-        sections.extend(map(self._generate_dispatcher_implementations_for_domain, self.domains_to_generate()))
+        sections.extend(list(map(self._generate_dispatcher_implementations_for_domain, self.domains_to_generate())))
         sections.append(Template(CppTemplates.ImplementationPostlude).substitute(None, **header_args))
         return "\n\n".join(sections)
 
index 7548d63..844aa7d 100755 (executable)
@@ -31,10 +31,16 @@ import string
 from operator import methodcaller
 from string import Template
 
-from cpp_generator import CppGenerator
-from cpp_generator_templates import CppGeneratorTemplates as CppTemplates
-from generator import Generator, ucfirst
-from models import EnumType, ObjectType, PrimitiveType, AliasedType, ArrayType, Frameworks
+try:
+    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
+except ValueError:
+    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 +68,8 @@ class CppProtocolTypesHeaderGenerator(CppGenerator):
         sections.append(self._generate_forward_declarations(domains))
         sections.append(self._generate_typedefs(domains))
         sections.extend(self._generate_enum_constant_value_conversion_methods())
-        builder_sections = map(self._generate_builders_for_domain, domains)
-        sections.extend(filter(lambda section: len(section) > 0, builder_sections))
+        builder_sections = list(map(self._generate_builders_for_domain, domains))
+        sections.extend([section for section in builder_sections if len(section) > 0])
         sections.append(self._generate_forward_declarations_for_binding_traits(domains))
         sections.extend(self._generate_declarations_for_enum_conversion_methods(domains))
         sections.append('} // namespace Protocol')
@@ -88,8 +94,8 @@ class CppProtocolTypesHeaderGenerator(CppGenerator):
 
         for domain in domains:
             declaration_types = [decl.type for decl in self.type_declarations_for_domain(domain)]
-            object_types = filter(lambda _type: isinstance(_type, ObjectType), declaration_types)
-            enum_types = filter(lambda _type: isinstance(_type, EnumType), declaration_types)
+            object_types = [_type for _type in declaration_types if isinstance(_type, ObjectType)]
+            enum_types = [_type for _type in declaration_types if isinstance(_type, EnumType)]
             sorted(object_types, key=methodcaller('raw_name'))
             sorted(enum_types, key=methodcaller('raw_name'))
 
@@ -114,8 +120,8 @@ class CppProtocolTypesHeaderGenerator(CppGenerator):
 """ % '\n\n'.join(sections)
 
     def _generate_typedefs(self, domains):
-        sections = map(self._generate_typedefs_for_domain, domains)
-        sections = filter(lambda text: len(text) > 0, sections)
+        sections = list(map(self._generate_typedefs_for_domain, domains))
+        sections = [text for text in sections if len(text) > 0]
 
         if len(sections) == 0:
             return ''
@@ -126,8 +132,8 @@ class CppProtocolTypesHeaderGenerator(CppGenerator):
 
     def _generate_typedefs_for_domain(self, domain):
         type_declarations = self.type_declarations_for_domain(domain)
-        primitive_declarations = filter(lambda decl: isinstance(decl.type, AliasedType), type_declarations)
-        array_declarations = filter(lambda decl: isinstance(decl.type, ArrayType), type_declarations)
+        primitive_declarations = [decl for decl in type_declarations if isinstance(decl.type, AliasedType)]
+        array_declarations = [decl for decl in type_declarations if isinstance(decl.type, ArrayType)]
         if len(primitive_declarations) == 0 and len(array_declarations) == 0:
             return ''
 
@@ -187,7 +193,7 @@ class CppProtocolTypesHeaderGenerator(CppGenerator):
             elif isinstance(type_declaration.type, ObjectType):
                 sections.append(self._generate_class_for_object_declaration(type_declaration, domain))
 
-        sections = filter(lambda section: len(section) > 0, sections)
+        sections = [section for section in sections if len(section) > 0]
         if len(sections) == 0:
             return ''
 
@@ -201,9 +207,9 @@ class CppProtocolTypesHeaderGenerator(CppGenerator):
         if len(type_declaration.type_members) == 0:
             return ''
 
-        enum_members = filter(lambda member: isinstance(member.type, EnumType) and member.type.is_anonymous, type_declaration.type_members)
-        required_members = filter(lambda member: not member.is_optional, type_declaration.type_members)
-        optional_members = filter(lambda member: member.is_optional, type_declaration.type_members)
+        enum_members = [member for member in type_declaration.type_members if isinstance(member.type, EnumType) and member.type.is_anonymous]
+        required_members = [member for member in type_declaration.type_members if not member.is_optional]
+        optional_members = [member for member in type_declaration.type_members if member.is_optional]
         object_name = type_declaration.type_name
 
         lines = []
@@ -262,7 +268,7 @@ class CppProtocolTypesHeaderGenerator(CppGenerator):
             else:
                 return '    ' + line
 
-        indented_lines = map(apply_indentation, self._generate_struct_for_enum_type(enum_member.member_name, enum_member.type))
+        indented_lines = list(map(apply_indentation, self._generate_struct_for_enum_type(enum_member.member_name, enum_member.type)))
         return '\n'.join(indented_lines)
 
     def _generate_struct_for_enum_type(self, enum_name, enum_type):
@@ -276,7 +282,7 @@ class CppProtocolTypesHeaderGenerator(CppGenerator):
 
     def _generate_builder_state_enum(self, type_declaration):
         lines = []
-        required_members = filter(lambda member: not member.is_optional, type_declaration.type_members)
+        required_members = [member for member in type_declaration.type_members if not member.is_optional]
         enum_values = []
 
         lines.append('    enum {')
@@ -344,7 +350,7 @@ class CppProtocolTypesHeaderGenerator(CppGenerator):
 
         for domain in domains:
             type_declarations = self.type_declarations_for_domain(domain)
-            declarations_to_generate = filter(lambda decl: self.type_needs_shape_assertions(decl.type), type_declarations)
+            declarations_to_generate = [decl for decl in type_declarations if self.type_needs_shape_assertions(decl.type)]
 
             for type_declaration in declarations_to_generate:
                 for type_member in type_declaration.type_members:
@@ -393,8 +399,8 @@ class CppProtocolTypesHeaderGenerator(CppGenerator):
         for domain in domains:
             type_declarations = self.type_declarations_for_domain(domain)
             declaration_types = [decl.type for decl in type_declarations]
-            object_types = filter(lambda _type: isinstance(_type, ObjectType), declaration_types)
-            enum_types = filter(lambda _type: isinstance(_type, EnumType), declaration_types)
+            object_types = [_type for _type in declaration_types if isinstance(_type, ObjectType)]
+            enum_types = [_type for _type in declaration_types if isinstance(_type, EnumType)]
             if len(object_types) + len(enum_types) == 0:
                 continue
 
@@ -432,7 +438,7 @@ class CppProtocolTypesHeaderGenerator(CppGenerator):
         for domain in domains:
             type_declarations = self.type_declarations_for_domain(domain)
             declaration_types = [decl.type for decl in type_declarations]
-            enum_types = filter(lambda _type: isinstance(_type, EnumType), declaration_types)
+            enum_types = list(filter(lambda _type: isinstance(_type, EnumType), declaration_types))
 
             if len(enum_types) == 0:
                 continue
index 5e7aec2..0800d05 100755 (executable)
@@ -30,10 +30,16 @@ import string
 from string import Template
 from operator import methodcaller
 
-from cpp_generator import CppGenerator
-from cpp_generator_templates import CppGeneratorTemplates as CppTemplates
-from generator import Generator, ucfirst
-from models import AliasedType, ArrayType, EnumType, ObjectType
+try:
+    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
+except ValueError:
+    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 +71,8 @@ class CppProtocolTypesImplementationGenerator(CppGenerator):
         sections.append('namespace Protocol {')
         sections.extend(self._generate_enum_mapping_and_conversion_methods(domains))
         sections.append(self._generate_open_field_names())
-        builder_sections = map(self._generate_builders_for_domain, domains)
-        sections.extend(filter(lambda section: len(section) > 0, builder_sections))
+        builder_sections = list(map(self._generate_builders_for_domain, domains))
+        sections.extend([section for section in builder_sections if len(section) > 0])
         sections.append('} // namespace Protocol')
         sections.append(Template(CppTemplates.ImplementationPostlude).substitute(None, **header_args))
 
@@ -128,8 +134,8 @@ class CppProtocolTypesImplementationGenerator(CppGenerator):
 
         type_declarations = self.type_declarations_for_domain(domain)
         declaration_types = [decl.type for decl in type_declarations]
-        object_types = filter(lambda _type: isinstance(_type, ObjectType), declaration_types)
-        enum_types = filter(lambda _type: isinstance(_type, EnumType), declaration_types)
+        object_types = [_type for _type in declaration_types if isinstance(_type, ObjectType)]
+        enum_types = [_type for _type in declaration_types if isinstance(_type, EnumType)]
         if len(object_types) + len(enum_types) == 0:
             return ''
 
@@ -156,8 +162,8 @@ class CppProtocolTypesImplementationGenerator(CppGenerator):
         sections = []
         sections.append('namespace %s {' % self.helpers_namespace())
         sections.extend(self._generate_enum_mapping())
-        enum_parser_sections = map(self._generate_enum_conversion_methods_for_domain, domains)
-        sections.extend(filter(lambda section: len(section) > 0, enum_parser_sections))
+        enum_parser_sections = list(map(self._generate_enum_conversion_methods_for_domain, domains))
+        sections.extend([section for section in enum_parser_sections if len(section) > 0])
         if len(sections) == 1:
             return []  # No declarations to emit, just the namespace.
 
@@ -168,7 +174,7 @@ class CppProtocolTypesImplementationGenerator(CppGenerator):
         lines = []
         for domain in self.domains_to_generate():
             type_declarations = self.type_declarations_for_domain(domain)
-            for type_declaration in filter(lambda decl: Generator.type_has_open_fields(decl.type), type_declarations):
+            for type_declaration in [decl for decl in type_declarations if Generator.type_has_open_fields(decl.type)]:
                 open_members = Generator.open_fields(type_declaration)
                 for type_member in sorted(open_members, key=lambda member: member.member_name):
                     field_name = '::'.join(['Inspector', 'Protocol', domain.domain_name, ucfirst(type_declaration.type_name), ucfirst(type_member.member_name)])
@@ -179,7 +185,7 @@ class CppProtocolTypesImplementationGenerator(CppGenerator):
     def _generate_builders_for_domain(self, domain):
         sections = []
         type_declarations = self.type_declarations_for_domain(domain)
-        declarations_to_generate = filter(lambda decl: self.type_needs_shape_assertions(decl.type), type_declarations)
+        declarations_to_generate = [decl for decl in type_declarations if self.type_needs_shape_assertions(decl.type)]
 
         for type_declaration in declarations_to_generate:
             for type_member in type_declaration.type_members:
@@ -200,8 +206,8 @@ class CppProtocolTypesImplementationGenerator(CppGenerator):
         return Template(CppTemplates.ProtocolObjectRuntimeCast).substitute(None, **args)
 
     def _generate_assertion_for_object_declaration(self, object_declaration):
-        required_members = filter(lambda member: not member.is_optional, object_declaration.type_members)
-        optional_members = filter(lambda member: member.is_optional, object_declaration.type_members)
+        required_members = [member for member in object_declaration.type_members if not member.is_optional]
+        optional_members = [member for member in object_declaration.type_members if member.is_optional]
         should_count_properties = not Generator.type_has_open_fields(object_declaration.type)
         lines = []
 
index 93307a8..a15f289 100755 (executable)
@@ -30,9 +30,14 @@ import logging
 import string
 from string import Template
 
-from generator import Generator, ucfirst
-from generator_templates import GeneratorTemplates as Templates
-from models import EnumType
+try:
+    from .generator import Generator, ucfirst
+    from .generator_templates import GeneratorTemplates as Templates
+    from .models import EnumType
+except ValueError:
+    from generator import Generator, ucfirst
+    from generator_templates import GeneratorTemplates as Templates
+    from models import EnumType
 
 log = logging.getLogger('global')
 
@@ -46,16 +51,16 @@ class JSBackendCommandsGenerator(Generator):
 
     def should_generate_domain(self, domain):
         type_declarations = self.type_declarations_for_domain(domain)
-        domain_enum_types = filter(lambda declaration: isinstance(declaration.type, EnumType), type_declarations)
+        domain_enum_types = [declaration for declaration in type_declarations if isinstance(declaration.type, EnumType)]
         return len(self.commands_for_domain(domain)) > 0 or len(self.events_for_domain(domain)) > 0 or len(domain_enum_types) > 0
 
     def domains_to_generate(self):
-        return filter(self.should_generate_domain, Generator.domains_to_generate(self))
+        return list(filter(self.should_generate_domain, Generator.domains_to_generate(self)))
 
     def generate_output(self):
         sections = []
         sections.append(self.generate_license())
-        sections.extend(map(self.generate_domain, self.domains_to_generate()))
+        sections.extend(list(map(self.generate_domain, self.domains_to_generate())))
         return "\n\n".join(sections)
 
     def generate_domain(self, domain):
@@ -70,7 +75,7 @@ class JSBackendCommandsGenerator(Generator):
         commands = self.commands_for_domain(domain)
         events = self.events_for_domain(domain)
 
-        has_async_commands = any(map(lambda command: command.is_async, commands))
+        has_async_commands = any([command.is_async for command in commands])
         if len(events) > 0 or has_async_commands:
             lines.append('InspectorBackend.register%(domain)sDispatcher = InspectorBackend.registerDomainDispatcher.bind(InspectorBackend, "%(domain)s");' % args)
 
index 0035756..05122c6 100755 (executable)
@@ -30,11 +30,18 @@ import string
 import re
 from string import Template
 
-from cpp_generator import CppGenerator
-from generator import Generator
-from models import Frameworks
-from objc_generator import ObjCGenerator
-from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates
+try:
+    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
+except ValueError:
+    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 +54,7 @@ class ObjCBackendDispatcherHeaderGenerator(ObjCGenerator):
         return '%sBackendDispatchers.h' % self.protocol_name()
 
     def domains_to_generate(self):
-        return filter(self.should_generate_commands_for_domain, Generator.domains_to_generate(self))
+        return list(filter(self.should_generate_commands_for_domain, Generator.domains_to_generate(self)))
 
     def generate_output(self):
         headers = [
@@ -64,7 +71,7 @@ class ObjCBackendDispatcherHeaderGenerator(ObjCGenerator):
         sections = []
         sections.append(self.generate_license())
         sections.append(Template(ObjCTemplates.BackendDispatcherHeaderPrelude).substitute(None, **header_args))
-        sections.extend(map(self._generate_objc_handler_declarations_for_domain, domains))
+        sections.extend(list(map(self._generate_objc_handler_declarations_for_domain, domains)))
         sections.append(Template(ObjCTemplates.BackendDispatcherHeaderPostlude).substitute(None, **header_args))
         return '\n\n'.join(sections)
 
index ad56165..76907ba 100755 (executable)
@@ -30,11 +30,18 @@ import string
 import re
 from string import Template
 
-from cpp_generator import CppGenerator
-from generator import Generator
-from models import PrimitiveType, EnumType, AliasedType, Frameworks
-from objc_generator import ObjCTypeCategory, ObjCGenerator, join_type_and_name
-from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates
+try:
+    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
+except ValueError:
+    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 +54,7 @@ class ObjCBackendDispatcherImplementationGenerator(ObjCGenerator):
         return '%sBackendDispatchers.mm' % self.protocol_name()
 
     def domains_to_generate(self):
-        return filter(self.should_generate_commands_for_domain, Generator.domains_to_generate(self))
+        return list(filter(self.should_generate_commands_for_domain, Generator.domains_to_generate(self)))
 
     def generate_output(self):
         secondary_headers = [
@@ -65,7 +72,7 @@ class ObjCBackendDispatcherImplementationGenerator(ObjCGenerator):
         sections = []
         sections.append(self.generate_license())
         sections.append(Template(ObjCTemplates.BackendDispatcherImplementationPrelude).substitute(None, **header_args))
-        sections.extend(map(self._generate_handler_implementation_for_domain, domains))
+        sections.extend(list(map(self._generate_handler_implementation_for_domain, domains)))
         sections.append(Template(ObjCTemplates.BackendDispatcherImplementationPostlude).substitute(None, **header_args))
         return '\n\n'.join(sections)
 
@@ -114,7 +121,7 @@ class ObjCBackendDispatcherImplementationGenerator(ObjCGenerator):
         if command.return_parameters:
             lines.append('        Ref<JSON::Object> resultObject = JSON::Object::create();')
 
-            required_pointer_parameters = filter(lambda parameter: not parameter.is_optional and ObjCGenerator.is_type_objc_pointer_type(parameter.type), command.return_parameters)
+            required_pointer_parameters = [parameter for parameter in command.return_parameters if not parameter.is_optional and ObjCGenerator.is_type_objc_pointer_type(parameter.type)]
             for parameter in required_pointer_parameters:
                 var_name = ObjCGenerator.identifier_to_objc_identifier(parameter.parameter_name)
                 lines.append('        THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(%s, @"%s");' % (var_name, var_name))
@@ -122,7 +129,7 @@ class ObjCBackendDispatcherImplementationGenerator(ObjCGenerator):
                 if objc_array_class and objc_array_class.startswith(self.objc_prefix()):
                     lines.append('        THROW_EXCEPTION_FOR_BAD_TYPE_IN_ARRAY(%s, [%s class]);' % (var_name, objc_array_class))
 
-            optional_pointer_parameters = filter(lambda parameter: parameter.is_optional and ObjCGenerator.is_type_objc_pointer_type(parameter.type), command.return_parameters)
+            optional_pointer_parameters = [parameter for parameter in command.return_parameters if parameter.is_optional and ObjCGenerator.is_type_objc_pointer_type(parameter.type)]
             for parameter in optional_pointer_parameters:
                 var_name = ObjCGenerator.identifier_to_objc_identifier(parameter.parameter_name)
                 lines.append('        THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(%s, @"%s");' % (var_name, var_name))
index a232e2c..6c3dd76 100755 (executable)
@@ -29,9 +29,14 @@ import logging
 import string
 from string import Template
 
-from generator import Generator
-from objc_generator import ObjCGenerator
-from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates
+try:
+    from .generator import Generator
+    from .objc_generator import ObjCGenerator
+    from .objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates
+except ValueError:
+    from generator import Generator
+    from objc_generator import ObjCGenerator
+    from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates
 
 log = logging.getLogger('global')
 
index 910bcba..922b608 100755 (executable)
@@ -29,9 +29,14 @@ import logging
 import string
 from string import Template
 
-from generator import Generator
-from objc_generator import ObjCGenerator
-from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates
+try:
+    from .generator import Generator
+    from .objc_generator import ObjCGenerator
+    from .objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates
+except ValueError:
+    from generator import Generator
+    from objc_generator import ObjCGenerator
+    from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates
 
 log = logging.getLogger('global')
 
index 654f9b4..381395d 100755 (executable)
@@ -29,10 +29,16 @@ import logging
 import string
 from string import Template
 
-from cpp_generator import CppGenerator
-from generator import Generator, ucfirst
-from objc_generator import ObjCGenerator
-from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates
+try:
+    from .cpp_generator import CppGenerator
+    from .generator import Generator, ucfirst
+    from .objc_generator import ObjCGenerator
+    from .objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates
+except ValueError:
+    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 +51,7 @@ class ObjCFrontendDispatcherImplementationGenerator(ObjCGenerator):
         return '%sEventDispatchers.mm' % self.protocol_name()
 
     def domains_to_generate(self):
-        return filter(self.should_generate_events_for_domain, Generator.domains_to_generate(self))
+        return list(filter(self.should_generate_events_for_domain, Generator.domains_to_generate(self)))
 
     def generate_output(self):
         secondary_headers = [
@@ -62,7 +68,7 @@ class ObjCFrontendDispatcherImplementationGenerator(ObjCGenerator):
         sections = []
         sections.append(self.generate_license())
         sections.append(Template(ObjCTemplates.ImplementationPrelude).substitute(None, **header_args))
-        sections.extend(map(self._generate_event_dispatcher_implementations, domains))
+        sections.extend(list(map(self._generate_event_dispatcher_implementations, domains)))
         sections.append(Template(ObjCTemplates.ImplementationPostlude).substitute(None, **header_args))
         return '\n\n'.join(sections)
 
@@ -100,7 +106,7 @@ class ObjCFrontendDispatcherImplementationGenerator(ObjCGenerator):
         lines.append('    const FrontendRouter& router = _controller->frontendRouter();')
         lines.append('')
 
-        required_pointer_parameters = filter(lambda parameter: not parameter.is_optional and ObjCGenerator.is_type_objc_pointer_type(parameter.type), event.event_parameters)
+        required_pointer_parameters = [parameter for parameter in event.event_parameters if not parameter.is_optional and ObjCGenerator.is_type_objc_pointer_type(parameter.type)]
         for parameter in required_pointer_parameters:
             var_name = ObjCGenerator.identifier_to_objc_identifier(parameter.parameter_name)
             lines.append('    THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(%s, @"%s");' % (var_name, var_name))
@@ -108,7 +114,7 @@ class ObjCFrontendDispatcherImplementationGenerator(ObjCGenerator):
             if objc_array_class and objc_array_class.startswith(self.objc_prefix()):
                 lines.append('    THROW_EXCEPTION_FOR_BAD_TYPE_IN_ARRAY(%s, [%s class]);' % (var_name, objc_array_class))
 
-        optional_pointer_parameters = filter(lambda parameter: parameter.is_optional and ObjCGenerator.is_type_objc_pointer_type(parameter.type), event.event_parameters)
+        optional_pointer_parameters = [parameter for parameter in event.event_parameters if parameter.is_optional and ObjCGenerator.is_type_objc_pointer_type(parameter.type)]
         for parameter in optional_pointer_parameters:
             var_name = ObjCGenerator.identifier_to_objc_identifier(parameter.parameter_name)
             lines.append('    THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(%s, @"%s");' % (var_name, var_name))
index a8343e6..b47cbcb 100755 (executable)
@@ -29,10 +29,16 @@ import logging
 import string
 from string import Template
 
-from generator import Generator, ucfirst
-from models import ObjectType, EnumType, Platforms
-from objc_generator import ObjCGenerator, join_type_and_name
-from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates
+try:
+    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
+except ValueError:
+    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 +66,9 @@ class ObjCHeaderGenerator(ObjCGenerator):
         }
 
         domains = self.domains_to_generate()
-        type_domains = filter(self.should_generate_types_for_domain, domains)
-        command_domains = filter(self.should_generate_commands_for_domain, domains)
-        event_domains = filter(self.should_generate_events_for_domain, domains)
+        type_domains = list(filter(self.should_generate_types_for_domain, domains))
+        command_domains = list(filter(self.should_generate_commands_for_domain, domains))
+        event_domains = list(filter(self.should_generate_events_for_domain, domains))
 
         # FIXME: <https://webkit.org/b/138222> Web Inspector: Reduce unnecessary enums/types generated in ObjC Protocol Interfaces
         # Currently we generate enums/types for all types in the type_domains. For the built-in
@@ -72,14 +78,14 @@ class ObjCHeaderGenerator(ObjCGenerator):
         sections = []
         sections.append(self.generate_license())
         sections.append(Template(ObjCTemplates.HeaderPrelude).substitute(None, **header_args))
-        sections.append('\n'.join(filter(None, map(self._generate_forward_declarations, type_domains))))
+        sections.append('\n'.join([_f for _f in map(self._generate_forward_declarations, type_domains) if _f]))
         sections.append(self._generate_enum_for_platforms())
-        sections.append('\n'.join(filter(None, map(self._generate_enums, type_domains))))
-        sections.append('\n'.join(filter(None, map(self._generate_types, type_domains))))
+        sections.append('\n'.join([_f for _f in map(self._generate_enums, type_domains) if _f]))
+        sections.append('\n'.join([_f for _f in map(self._generate_types, type_domains) if _f]))
 
         if self.get_generator_setting('generate_backend', False):
-            sections.append('\n\n'.join(filter(None, map(self._generate_command_protocols, command_domains))))
-            sections.append('\n\n'.join(filter(None, map(self._generate_event_interfaces, event_domains))))
+            sections.append('\n\n'.join([_f for _f in map(self._generate_command_protocols, command_domains) if _f]))
+            sections.append('\n\n'.join([_f for _f in map(self._generate_event_interfaces, event_domains) if _f]))
 
         sections.append(Template(ObjCTemplates.HeaderPostlude).substitute(None))
         return '\n\n'.join(sections)
@@ -171,8 +177,8 @@ class ObjCHeaderGenerator(ObjCGenerator):
             lines.append('- (instancetype)initWithPayload:(NSDictionary<NSString *, id> *)payload;')
             lines.append('- (instancetype)initWithProtocolObject:(RWIProtocolJSONObject *)jsonObject;')
 
-        required_members = filter(lambda member: not member.is_optional, declaration.type_members)
-        optional_members = filter(lambda member: member.is_optional, declaration.type_members)
+        required_members = [member for member in declaration.type_members if not member.is_optional]
+        optional_members = [member for member in declaration.type_members if member.is_optional]
         if required_members:
             lines.append(self._generate_init_method_for_required_members(domain, declaration, required_members))
         for member in required_members:
index b6e4ad5..a7339d2 100755 (executable)
@@ -29,9 +29,14 @@ import logging
 import string
 from string import Template
 
-from generator import Generator, ucfirst
-from objc_generator import ObjCGenerator
-from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates
+try:
+    from .generator import Generator, ucfirst
+    from .objc_generator import ObjCGenerator
+    from .objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates
+except ValueError:
+    from generator import Generator, ucfirst
+    from objc_generator import ObjCGenerator
+    from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates
 
 log = logging.getLogger('global')
 
@@ -55,12 +60,12 @@ class ObjCInternalHeaderGenerator(ObjCGenerator):
             'includes': '\n'.join(['#import ' + header for header in sorted(headers)]),
         }
 
-        event_domains = filter(self.should_generate_events_for_domain, self.domains_to_generate())
+        event_domains = list(filter(self.should_generate_events_for_domain, self.domains_to_generate()))
 
         sections = []
         sections.append(self.generate_license())
         sections.append(Template(ObjCTemplates.GenericHeaderPrelude).substitute(None, **header_args))
-        sections.append('\n\n'.join(filter(None, map(self._generate_event_dispatcher_private_interfaces, event_domains))))
+        sections.append('\n\n'.join([_f for _f in map(self._generate_event_dispatcher_private_interfaces, event_domains) if _f]))
         sections.append(Template(ObjCTemplates.GenericHeaderPostlude).substitute(None, **header_args))
         return '\n\n'.join(sections)
 
index 84cbdda..ce12a3a 100755 (executable)
@@ -29,10 +29,16 @@ import logging
 import string
 from string import Template
 
-from generator import Generator
-from models import EnumType, Frameworks, Platforms
-from objc_generator import ObjCGenerator
-from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates
+try:
+    from .generator import Generator
+    from .models import EnumType, Frameworks, Platforms
+    from .objc_generator import ObjCGenerator
+    from .objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates
+except ValueError:
+    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 +57,7 @@ class ObjCProtocolTypeConversionsHeaderGenerator(ObjCGenerator):
         return '%sTypeConversions.h' % self.protocol_name()
 
     def domains_to_generate(self):
-        return filter(self.should_generate_types_for_domain, Generator.domains_to_generate(self))
+        return list(filter(self.should_generate_types_for_domain, Generator.domains_to_generate(self)))
 
     def generate_output(self):
         headers = [
@@ -70,7 +76,7 @@ class ObjCProtocolTypeConversionsHeaderGenerator(ObjCGenerator):
         sections.append(Template(ObjCTemplates.TypeConversionsHeaderPrelude).substitute(None, **header_args))
         sections.append(Template(ObjCTemplates.TypeConversionsHeaderStandard).substitute(None))
         sections.append(self._generate_enum_conversion_for_platforms())
-        sections.extend(map(self._generate_enum_conversion_functions, domains))
+        sections.extend(list(map(self._generate_enum_conversion_functions, domains)))
         sections.append(Template(ObjCTemplates.TypeConversionsHeaderPostlude).substitute(None, **header_args))
         return '\n\n'.join(sections)
 
index 4293e3b..3d84bf0 100644 (file)
@@ -28,10 +28,16 @@ import logging
 import string
 from string import Template
 
-from generator import Generator
-from models import EnumType, ObjectType, ArrayType, AliasedType, PrimitiveType, Frameworks
-from objc_generator import ObjCGenerator
-from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates
+try:
+    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
+except ValueError:
+    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 +56,7 @@ class ObjCProtocolTypeConversionsImplementationGenerator(ObjCGenerator):
         return '%sTypeConversions.mm' % self.protocol_name()
 
     def domains_to_generate(self):
-        return filter(self.should_generate_types_for_domain, Generator.domains_to_generate(self))
+        return list(filter(self.should_generate_types_for_domain, Generator.domains_to_generate(self)))
 
     def generate_output(self):
         secondary_headers = [
index 0ba55ee..9cd98d7 100755 (executable)
@@ -29,10 +29,16 @@ import logging
 import string
 from string import Template
 
-from generator import Generator, ucfirst
-from models import ObjectType, EnumType, Frameworks
-from objc_generator import ObjCTypeCategory, ObjCGenerator
-from objc_generator_templates import ObjCGeneratorTemplates as ObjCTemplates
+try:
+    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
+except ValueError:
+    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 +57,7 @@ class ObjCProtocolTypesImplementationGenerator(ObjCGenerator):
         return '%sTypes.mm' % self.protocol_name()
 
     def domains_to_generate(self):
-        return filter(self.should_generate_types_for_domain, Generator.domains_to_generate(self))
+        return list(filter(self.should_generate_types_for_domain, Generator.domains_to_generate(self)))
 
     def generate_output(self):
         secondary_headers = [
@@ -75,7 +81,7 @@ class ObjCProtocolTypesImplementationGenerator(ObjCGenerator):
         sections = []
         sections.append(self.generate_license())
         sections.append(Template(ObjCTemplates.ImplementationPrelude).substitute(None, **header_args))
-        sections.extend(map(self.generate_type_implementations, domains))
+        sections.extend(list(map(self.generate_type_implementations, domains)))
         sections.append(Template(ObjCTemplates.ImplementationPostlude).substitute(None, **header_args))
         return '\n\n'.join(sections)
 
@@ -95,7 +101,7 @@ class ObjCProtocolTypesImplementationGenerator(ObjCGenerator):
             lines.append('')
             lines.append(self._generate_init_method_for_payload(domain, declaration))
             lines.append(self._generate_init_method_for_protocol_object(domain, declaration))
-        required_members = filter(lambda member: not member.is_optional, declaration.type_members)
+        required_members = [member for member in declaration.type_members if not member.is_optional]
         if required_members:
             lines.append('')
             lines.append(self._generate_init_method_for_required_members(domain, declaration, required_members))
@@ -167,7 +173,7 @@ class ObjCProtocolTypesImplementationGenerator(ObjCGenerator):
         lines.append('        return nil;')
         lines.append('')
 
-        required_pointer_members = filter(lambda member: ObjCGenerator.is_type_objc_pointer_type(member.type), required_members)
+        required_pointer_members = [member for member in required_members if ObjCGenerator.is_type_objc_pointer_type(member.type)]
         if required_pointer_members:
             for member in required_pointer_members:
                 var_name = ObjCGenerator.identifier_to_objc_identifier(member.member_name)
index 3f4966b..1c9892d 100755 (executable)
@@ -29,8 +29,12 @@ import os.path
 import re
 from string import Template
 
-from generator_templates import GeneratorTemplates as Templates
-from models import PrimitiveType, ObjectType, ArrayType, EnumType, AliasedType, Frameworks, Platforms
+try:
+    from .generator_templates import GeneratorTemplates as Templates
+    from .models import PrimitiveType, ObjectType, ArrayType, EnumType, AliasedType, Frameworks, Platforms
+except ValueError:
+    from generator_templates import GeneratorTemplates as Templates
+    from models import PrimitiveType, ObjectType, ArrayType, EnumType, AliasedType, Frameworks, Platforms
 
 log = logging.getLogger('global')
 
@@ -141,7 +145,7 @@ class Generator:
 
     # These methods are overridden by subclasses.
     def non_supplemental_domains(self):
-        return filter(lambda domain: not domain.is_supplemental, self.model().domains)
+        return [domain for domain in self.model().domains if not domain.is_supplemental]
 
     def domains_to_generate(self):
         return self.non_supplemental_domains()
@@ -177,7 +181,7 @@ class Generator:
         fields = set(_TYPES_WITH_OPEN_FIELDS.get(type_declaration.type.qualified_name(), []))
         if not fields:
             return type_declaration.type_members
-        return filter(lambda member: member.member_name in fields, type_declaration.type_members)
+        return [member for member in type_declaration.type_members if member.member_name in fields]
 
     def type_needs_shape_assertions(self, _type):
         if not hasattr(self, "_types_needing_shape_assertions"):
@@ -190,7 +194,7 @@ class Generator:
     # set of types will not be automatically regenerated on subsequent calls to
     # Generator.types_needing_shape_assertions().
     def calculate_types_requiring_shape_assertions(self, domains):
-        domain_names = map(lambda domain: domain.domain_name, domains)
+        domain_names = [domain.domain_name for domain in domains]
         log.debug("> Calculating types that need shape assertions (eligible domains: %s)" % ", ".join(domain_names))
 
         # Mutates the passed-in set; this simplifies checks to prevent infinite recursion.
@@ -246,7 +250,7 @@ class Generator:
         for _type in all_types:
             if not isinstance(_type, EnumType):
                 continue
-            map(self._assign_encoding_for_enum_value, _type.enum_values())
+            list(map(self._assign_encoding_for_enum_value, _type.enum_values()))
 
     def _assign_encoding_for_enum_value(self, enum_value):
         if enum_value in self._enum_value_encodings:
@@ -280,7 +284,7 @@ class Generator:
             return _ALWAYS_SPECIALCASED_ENUM_VALUE_LOOKUP_TABLE[match.group(1).upper()]
 
         # Split on hyphen, introduce camelcase, and force uppercasing of acronyms.
-        subwords = map(ucfirst, _ENUM_IDENTIFIER_RENAME_MAP.get(enum_value, enum_value).split('-'))
+        subwords = list(map(ucfirst, _ENUM_IDENTIFIER_RENAME_MAP.get(enum_value, enum_value).split('-')))
         return re.sub(re.compile(regex, re.IGNORECASE), replaceCallback, "".join(subwords))
 
     @staticmethod
index ca91d71..d09b242 100755 (executable)
@@ -35,7 +35,7 @@ def ucfirst(str):
 
 
 def find_duplicates(l):
-    return [key for key, count in collections.Counter(l).items() if count > 1]
+    return [key for key, count in list(collections.Counter(l).items()) if count > 1]
 
 
 _FRAMEWORK_CONFIG_MAP = {
index e52f315..25e25c6 100755 (executable)
 # THE POSSIBILITY OF SUCH DAMAGE.
 
 import logging
-from generator import Generator, ucfirst
-from models import PrimitiveType, ObjectType, ArrayType, EnumType, AliasedType, Frameworks
+try:
+    from .generator import Generator, ucfirst
+    from .models import PrimitiveType, ObjectType, ArrayType, EnumType, AliasedType, Frameworks
+except ValueError:
+    from generator import Generator, ucfirst
+    from models import PrimitiveType, ObjectType, ArrayType, EnumType, AliasedType, Frameworks
 
 log = logging.getLogger('global')
 
@@ -50,7 +54,7 @@ _OBJC_IDENTIFIER_RENAME_MAP = {
     'id': 'identifier',  # Page.Frame.id, Runtime.ExecutionContextDescription.id, Debugger.BreakpointAction.id
 }
 
-_OBJC_IDENTIFIER_REVERSE_RENAME_MAP = dict((v, k) for k, v in _OBJC_IDENTIFIER_RENAME_MAP.iteritems())
+_OBJC_IDENTIFIER_REVERSE_RENAME_MAP = dict((v, k) for k, v in _OBJC_IDENTIFIER_RENAME_MAP.items())
 
 
 class ObjCTypeCategory:
index 579c018..68a4a52 100755 (executable)
@@ -49,7 +49,7 @@ try:
 # When copying generator files to JavaScriptCore's private headers on Mac,
 # the codegen/ module directory is flattened. So, import directly.
 except ImportError as e:
-    # log.error(e) # Uncomment this to debug early import errors.
+    #log.error(e) # Uncomment this to debug early import errors.
     import models
     from models import *
     from generator import *
index 16887ec..f0b6b58 100755 (executable)
@@ -71,7 +71,7 @@ class Wasm:
         # We need to do this because python is dumb and won't let me use self in the lambda, which is ridiculous.
         if ret == None:
             ret = lambda op: {"name": op, "opcode": self.opcodes[op]}
-        for op in self.opcodes.iterkeys():
+        for op in self.opcodes.keys():
             if filter(self.opcodes[op]):
                 yield ret(op)
 
index a103bcd..b897779 100644 (file)
@@ -31,7 +31,6 @@ import optparse
 import os
 import re
 import sys
-from sets import Set
 
 header = """/*
 * Copyright (C) 2016 Apple Inc. All rights reserved.
@@ -80,7 +79,7 @@ def openOrExit(path, mode):
             os.makedirs(dirname)
         return open(path, mode)
     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)
 
 class Canonicalize:
@@ -93,7 +92,7 @@ class Canonicalize:
         self.canonicalGroups[mapping].append(code)
         
     def readCaseFolding(self, file):
-        codesSeen = Set()
+        codesSeen = set()
         for line in file:
             line = line.split('#', 1)[0]
             line = line.rstrip()
@@ -154,8 +153,8 @@ class Canonicalize:
         
         for i in range(len(characterSets)):
             characters = ""
-            set = characterSets[i]
-            for ch in set:
+            cur_set = characterSets[i]
+            for ch in cur_set:
                 characters = characters + "0x{character:04x}, ".format(character=ch)
             file.write("const UChar32 unicodeCharacterSet{index:d}[] = {{ {characters}0 }};\n".format(index=i, characters=characters))
 
@@ -189,7 +188,7 @@ if __name__ == "__main__":
     caseFoldingTxtPath = args[0]
     canonicalizeHPath = args[1]
     caseFoldingTxtFile = openOrExit(caseFoldingTxtPath, "r")
-    canonicalizeHFile = openOrExit(canonicalizeHPath, "wb")
+    canonicalizeHFile = openOrExit(canonicalizeHPath, "w")
 
     canonicalize = Canonicalize()
     canonicalize.readCaseFolding(caseFoldingTxtFile)
index f8bc680..ceb5c8f 100644 (file)
@@ -322,7 +322,7 @@ class PropertyData:
         insertLocation = None
         lowCodePoint = None
         highCodePoint = None
-        for idx in xrange(len(matches)):
+        for idx in range(len(matches)):
             match = matches[idx]
             if codePoint == match + 1:
                 lowCodePoint = match
@@ -351,22 +351,22 @@ class PropertyData:
             lowCodePoint = codePoint
             highCodePoint = codePoint
 
-        for idx in xrange(len(ranges)):
-            range = ranges[idx]
-            if lowCodePoint >= range[0] and highCodePoint <= range[1]:
+        for idx in range(len(ranges)):
+            cur_range = ranges[idx]
+            if lowCodePoint >= cur_range[0] and highCodePoint <= cur_range[1]:
                 return
-            if lowCodePoint <= (range[1] + 1) and highCodePoint >= (range[0] - 1):
+            if lowCodePoint <= (cur_range[1] + 1) and highCodePoint >= (cur_range[0] - 1):
                 while idx < len(ranges) and highCodePoint >= (ranges[idx][0] - 1):
-                    range = ranges[idx]
-                    lowCodePoint = min(lowCodePoint, range[0])
-                    highCodePoint = max(highCodePoint, range[1])
+                    cur_range = ranges[idx]
+                    lowCodePoint = min(lowCodePoint, cur_range[0])
+                    highCodePoint = max(highCodePoint, cur_range[1])
                     del ranges[idx]
-                    self.codePointCount = self.codePointCount - (range[1] - range[0]) - 1
+                    self.codePointCount = self.codePointCount - (cur_range[1] - cur_range[0]) - 1
 
                 ranges.insert(idx, (lowCodePoint, highCodePoint))
                 self.codePointCount = self.codePointCount + (highCodePoint - lowCodePoint) + 1
                 return
-            elif highCodePoint < range[0]:
+            elif highCodePoint < cur_range[0]:
                 if lowCodePoint != highCodePoint:
                     ranges.insert(idx, (lowCodePoint, highCodePoint))
                     self.codePointCount = self.codePointCount + (highCodePoint - lowCodePoint) + 1
@@ -384,7 +384,7 @@ class PropertyData:
 
     def addRangeUnorderedForMatchesAndRanges(self, lowCodePoint, highCodePoint, matches, ranges):
         if len(matches) and highCodePoint >= matches[0] and lowCodePoint <= matches[-1]:
-            for idx in xrange(len(matches)):
+            for idx in range(len(matches)):
                 match = matches[idx]
                 if lowCodePoint <= match and highCodePoint >= match:
                     while idx < len(matches) and highCodePoint >= matches[idx]:
@@ -414,22 +414,22 @@ class PropertyData:
                 elif highCodePoint < match:
                     break
 
-        for idx in xrange(len(ranges)):
-            range = ranges[idx]
-            if lowCodePoint >= range[0] and highCodePoint <= range[1]:
+        for idx in range(len(ranges)):
+            cur_range = ranges[idx]
+            if lowCodePoint >= cur_range[0] and highCodePoint <= cur_range[1]:
                 return
-            if lowCodePoint <= (range[1] + 1) and highCodePoint >= (range[0] - 1):
+            if lowCodePoint <= (cur_range[1] + 1) and highCodePoint >= (cur_range[0] - 1):
                 while idx < len(ranges) and highCodePoint >= (ranges[idx][0] - 1):
-                    range = ranges[idx]
-                    lowCodePoint = min(lowCodePoint, range[0])
-                    highCodePoint = max(highCodePoint, range[1])
+                    cur_range = ranges[idx]
+                    lowCodePoint = min(lowCodePoint, cur_range[0])
+                    highCodePoint = max(highCodePoint, cur_range[1])
                     del ranges[idx]
-                    self.codePointCount = self.codePointCount - (range[1] - range[0]) - 1
+                    self.codePointCount = self.codePointCount - (cur_range[1] - cur_range[0]) - 1
 
                 ranges.insert(idx, (lowCodePoint, highCodePoint))
                 self.codePointCount = self.codePointCount + (highCodePoint - lowCodePoint) + 1
                 return
-            elif highCodePoint < range[0]:
+            elif highCodePoint < cur_range[0]:
                 ranges.insert(idx, (lowCodePoint, highCodePoint))
                 self.codePointCount = self.codePointCount + (highCodePoint - lowCodePoint) + 1
                 return
@@ -459,13 +459,13 @@ class PropertyData:
                 self.addRangeUnorderedForMatchesAndRanges(firstUnicodeCodePoint, highCodePoint, self.unicodeMatches, self.unicodeRanges)
 
     def removeMatchFromRanges(self, codePoint, ranges):
-        for idx in xrange(len(ranges)):
-            range = ranges[idx]
-            if range[0] <= codePoint and codePoint <= range[1]:
+        for idx in range(len(ranges)):
+            cur_range = ranges[idx]
+            if cur_range[0] <= codePoint and codePoint <= cur_range[1]:
                 ranges.pop(idx)
-                if range[0] < codePoint and codePoint < range[1]:
-                    lowRange = (range[0], codePoint - 1)
-                    highRange = (codePoint + 1, range[1])
+                if cur_range[0] < codePoint and codePoint < cur_range[1]:
+                    lowRange = (cur_range[0], codePoint - 1)
+                    highRange = (codePoint + 1, cur_range[1])
                     # Since list.insert inserts before the index given, handle the high range first
                     if highRange[0] == highRange[1]:
                         self.addMatchUnordered(highRange[0])
@@ -476,14 +476,14 @@ class PropertyData:
                     else:
                         ranges.insert(idx, lowRange)
                 else:
-                    if range[0] == codePoint:
-                        range = (codePoint + 1, range[1])
+                    if cur_range[0] == codePoint:
+                        cur_range = (codePoint + 1, cur_range[1])
                     else:
-                        range = (range[0], codePoint - 1)
-                    if range[0] == range[1]:
-                        self.addMatchUnordered(range[0])
+                        cur_range = (cur_range[0], codePoint - 1)
+                    if cur_range[0] == cur_range[1]:
+                        self.addMatchUnordered(cur_range[0])
                     else:
-                        ranges.insert(idx, range)
+                        ranges.insert(idx, cur_range)
                 self.codePointCount = self.codePointCount - 1
                 return
 
@@ -742,13 +742,13 @@ class Scripts:
                     lowCodePoint = int(codePoints[:dotDot], 16)
                     highCodePoint = int(codePoints[dotDot + 2:], 16)
                     currentPropertyData.addRange(lowCodePoint, highCodePoint)
-                    for codePoint in xrange(lowCodePoint, highCodePoint + 1):
+                    for codePoint in range(lowCodePoint, highCodePoint + 1):
                         commonScriptExtenstionPropertyData.removeMatch(codePoint)
                         inheritedScriptExtensionPropertyData.removeMatch(codePoint)
 
         # For the scripts that don't have any additional extension codePoints, copy the script
         # data to the script extension with the same name
-        for scriptName, propertyData in self.scriptsByName.iteritems():
+        for scriptName, propertyData in self.scriptsByName.items():
             if scriptName not in self.scriptExtensionsByName:
                 self.scriptExtensionsByName[scriptName] = propertyData
 
@@ -948,7 +948,7 @@ if __name__ == "__main__":
 
     aliases = Aliases()
 
-    propertyDataHFile = openOrExit(unicodeProertyDataHPath, "wb")
+    propertyDataHFile = openOrExit(unicodeProertyDataHPath, "w")
 
     propertyDataHFile.write(header)
 
index cf0290b..d9ba4d0 100644 (file)
@@ -36,7 +36,7 @@ def stringHash(str):
     hash = stringHashingStartValue
 
     strLength = len(str)
-    characterPairs = strLength / 2
+    characterPairs = int(strLength / 2)
     remainder = strLength & 1
 
     # Main loop
index 7d7e73e..58ac17d 100644 (file)
@@ -1,3 +1,14 @@
+2018-09-21  Mike Gorse  <mgorse@suse.com>
+
+        Build tools should work when the /usr/bin/python is python3
+        https://bugs.webkit.org/show_bug.cgi?id=156674
+
+        Reviewed by Michael Catanzaro.
+
+        No new tests (no behavior change).
+
+        * platform/network/create-http-header-name-table: remove xreadlines.
+
 2018-09-21  Jer Noble  <jer.noble@apple.com>
 
         [EME] Introduce the concept of CDMInstanceSession.
index f5beb63..647cdd8 100755 (executable)
@@ -42,7 +42,7 @@ input_file = open(input_path)
 http_header_name_to_id = { }
 http_header_names = []
 
-for line in input_file.xreadlines():
+for line in input_file:
     http_header_name = line.strip()
     if not http_header_name or http_header_name[:2] == '//':
         continue
index e4c329a..ca8bcc5 100644 (file)
@@ -1,3 +1,13 @@
+2018-09-21  Mike Gorse  <mgorse@suse.com>
+
+        Build tools should work when the /usr/bin/python is python3
+        https://bugs.webkit.org/show_bug.cgi?id=156674
+
+        Reviewed by Michael Catanzaro.
+
+        * Scripts/copy-user-interface-resources.pl: Use $PYTHON if set
+        in the environment.
+
 2018-09-20  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: remove Visual Style CSS details sidebar panel
index eb311c6..00c38c1 100755 (executable)
@@ -176,6 +176,8 @@ my $eslintLicense = readLicenseFile(File::Spec->catfile($eslintPath, 'LICENSE'))
 my $threejsLicense = readLicenseFile(File::Spec->catfile($threejsPath, 'LICENSE'));
 make_path($protocolDir, $targetResourcePath);
 
+$python = $ENV{"PYTHON"} if defined($ENV{"PYTHON"});
+
 # Copy over dynamically loaded files from other frameworks, even if we aren't combining resources.
 copy(File::Spec->catfile($ENV{'JAVASCRIPTCORE_PRIVATE_HEADERS_DIR'}, 'InspectorBackendCommands.js'), File::Spec->catfile($protocolDir, 'InspectorBackendCommands.js')) or die "Copy of InspectorBackendCommands.js failed: $!";
 
index d659577..fd8d8dc 100644 (file)
@@ -21,9 +21,6 @@ if (NOT HAS_RUN_WEBKIT_COMMON)
     find_package(PerlModules COMPONENTS JSON::PP REQUIRED)
 
     find_package(PythonInterp 2.7.0 REQUIRED)
-    if (PYTHON_VERSION_MAJOR GREATER 2)
-        message(FATAL_ERROR "Python 2 is required, but Python ${PYTHON_VERSION_MAJOR} was found.")
-    endif ()
 
     # We cannot check for RUBY_FOUND because it is set only when the full package is installed and
     # the only thing we need is the interpreter. Unlike Python, cmake does not provide a macro