Title: [126558] trunk/Source
Revision
126558
Author
[email protected]
Date
2012-08-24 01:44:24 -0700 (Fri, 24 Aug 2012)

Log Message

Make it possible to build WebKit with Python 3 (and 2)
https://bugs.webkit.org/show_bug.cgi?id=94814

Source/WebCore:

Exceptions need a hack to work with both.
string.join was already deprecated in Python 2.
Relative imports are no longer supported, use package name instead.

Patch by Frederik Gladhorn <[email protected]> on 2012-08-23
Reviewed by Ryosuke Niwa.

* inspector/CodeGeneratorInspector.py:
(EnumConstants.get_enum_constant_code):
(TypeBindings.create_type_declaration_.EnumBinding.get_code_generator.CodeGenerator.generate_type_builder):
(Generator.go):
(Generator.process_event):
(Generator.process_command):

Source/WebKit2:

Patch by Frederik Gladhorn <[email protected]> on 2012-08-23
Reviewed by Ryosuke Niwa.

Exceptions need a hack to work with both.
string.join was already deprecated in Python 2.
Relative imports are no longer supported, use package name instead.

* Scripts/webkit2/messages.py:
* Scripts/webkit2/parser.py:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (126557 => 126558)


--- trunk/Source/WebCore/ChangeLog	2012-08-24 08:43:50 UTC (rev 126557)
+++ trunk/Source/WebCore/ChangeLog	2012-08-24 08:44:24 UTC (rev 126558)
@@ -1,3 +1,21 @@
+2012-08-23  Frederik Gladhorn  <[email protected]>
+
+        Make it possible to build WebKit with Python 3 (and 2)
+        https://bugs.webkit.org/show_bug.cgi?id=94814
+
+        Exceptions need a hack to work with both.
+        string.join was already deprecated in Python 2.
+        Relative imports are no longer supported, use package name instead.
+
+        Reviewed by Ryosuke Niwa.
+
+        * inspector/CodeGeneratorInspector.py:
+        (EnumConstants.get_enum_constant_code):
+        (TypeBindings.create_type_declaration_.EnumBinding.get_code_generator.CodeGenerator.generate_type_builder):
+        (Generator.go):
+        (Generator.process_event):
+        (Generator.process_command):
+
 2012-08-24  Allan Sandfeld Jensen  <[email protected]>
 
         Get rid of m_useLatchedWheelEventNode

Modified: trunk/Source/WebCore/inspector/CodeGeneratorInspector.py (126557 => 126558)


--- trunk/Source/WebCore/inspector/CodeGeneratorInspector.py	2012-08-24 08:43:50 UTC (rev 126557)
+++ trunk/Source/WebCore/inspector/CodeGeneratorInspector.py	2012-08-24 08:44:24 UTC (rev 126558)
@@ -32,7 +32,6 @@
 import sys
 import string
 import optparse
-from string import join
 try:
     import json
 except ImportError:
@@ -86,8 +85,10 @@
         raise Exception("Output .h directory must be specified")
     if not output_cpp_dirname:
         raise Exception("Output .cpp directory must be specified")
-except Exception, e:
-    sys.stderr.write("Failed to parse command-line arguments: %s\n\n" % e)
+except Exception:
+    # Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.html
+    exc = sys.exc_info()[1]
+    sys.stderr.write("Failed to parse command-line arguments: %s\n\n" % exc)
     sys.stderr.write("Usage: <script> Inspector.json --output_h_dir <output_header_dir> --output_cpp_dir <output_cpp_dir>\n")
     exit(1)
 
@@ -797,7 +798,7 @@
         output = []
         for item in cls.constants_:
             output.append("    \"" + item + "\"")
-        return join(output, ",\n") + "\n"
+        return ",\n".join(output) + "\n"
 
 
 # Typebuilder code is generated in several passes: first typedefs, then other classes.
@@ -926,7 +927,7 @@
                                         for enum_item in enum:
                                             enum_pos = EnumConstants.add_constant(enum_item)
                                             condition_list.append("s == \"%s\"" % enum_item)
-                                        validator_writer.newline("    ASSERT(%s);\n" % join(condition_list, " || "))
+                                        validator_writer.newline("    ASSERT(%s);\n" % " || ".join(condition_list))
                                     validator_writer.newline("}\n")
 
                                     if domain_guard:
@@ -2700,7 +2701,7 @@
             Generator.frontend_domain_class_lines.append(Templates.frontend_domain_class.substitute(None,
                 domainClassName=domain_name,
                 domainFieldName=domain_name_lower,
-                frontendDomainMethodDeclarations=join(flatten_list(frontend_method_declaration_lines), "")))
+                frontendDomainMethodDeclarations="".join(flatten_list(frontend_method_declaration_lines))))
 
             agent_interface_name = Capitalizer.lower_camel_case_to_upper(domain_name) + "CommandHandler"
             Generator.backend_agent_interface_list.append("    class %s {\n" % agent_interface_name)
@@ -2769,15 +2770,15 @@
                 backend_js_event_param_list.append("\"%s\"" % parameter_name)
             method_line_list.append("    %sMessage->setObject(\"params\", paramsObject);\n" % event_name)
         frontend_method_declaration_lines.append(
-            "        void %s(%s);\n" % (event_name, join(parameter_list, ", ")))
+            "        void %s(%s);\n" % (event_name, ", ".join(parameter_list)))
 
         Generator.frontend_method_list.append(Templates.frontend_method.substitute(None,
             domainName=domain_name, eventName=event_name,
-            parameters=join(parameter_list, ", "),
-            code=join(method_line_list, "")))
+            parameters=", ".join(parameter_list),
+            code="".join(method_line_list)))
 
         Generator.backend_js_domain_initializer_list.append("InspectorBackend.registerEvent(\"%s.%s\", [%s]);\n" % (
-            domain_name, event_name, join(backend_js_event_param_list, ", ")))
+            domain_name, event_name, ", ".join(backend_js_event_param_list)))
 
     @staticmethod
     def process_command(json_command, domain_name, agent_field_name, agent_interface_name):
@@ -2851,7 +2852,7 @@
 
                 js_param_list.append(js_param_text)
 
-            js_parameters_text = join(js_param_list, ", ")
+            js_parameters_text = ", ".join(js_param_list)
 
         response_cook_text = ""
         js_reply_list = "[]"
@@ -2900,9 +2901,9 @@
 
                 backend_js_reply_param_list.append("\"%s\"" % json_return_name)
 
-            js_reply_list = "[%s]" % join(backend_js_reply_param_list, ", ")
+            js_reply_list = "[%s]" % ", ".join(backend_js_reply_param_list)
 
-            response_cook_text = join(response_cook_list, "")
+            response_cook_text = "".join(response_cook_list)
 
             if len(response_cook_text) != 0:
                 response_cook_text = "        if (!error.length()) {\n" + response_cook_text + "        }"
@@ -2912,7 +2913,7 @@
             agentField="m_" + agent_field_name,
             methodInCode=method_in_code,
             methodOutCode=method_out_code,
-            agentCallParams=join(agent_call_param_list, ""),
+            agentCallParams="".join(agent_call_param_list),
             requestMessageObject=request_message_param,
             responseCook=response_cook_text,
             commandNameIndex=cmd_enum_name))
@@ -3090,38 +3091,38 @@
 
 
 backend_h_file.write(Templates.backend_h.substitute(None,
-    virtualSetters=join(Generator.backend_virtual_setters_list, "\n"),
-    agentInterfaces=join(flatten_list(Generator.backend_agent_interface_list), ""),
-    methodNamesEnumContent=join(Generator.method_name_enum_list, "\n")))
+    virtualSetters="\n".join(Generator.backend_virtual_setters_list),
+    agentInterfaces="".join(flatten_list(Generator.backend_agent_interface_list)),
+    methodNamesEnumContent="\n".join(Generator.method_name_enum_list)))
 
 backend_cpp_file.write(Templates.backend_cpp.substitute(None,
-    constructorInit=join(Generator.backend_constructor_init_list, "\n"),
-    setters=join(Generator.backend_setters_list, "\n"),
-    fieldDeclarations=join(Generator.backend_field_list, "\n"),
-    methodNameDeclarations=join(Generator.backend_method_name_declaration_list, "\n"),
-    methods=join(Generator.backend_method_implementation_list, "\n"),
-    methodDeclarations=join(Generator.backend_method_declaration_list, "\n"),
-    messageHandlers=join(Generator.method_handler_list, "\n")))
+    constructorInit="\n".join(Generator.backend_constructor_init_list),
+    setters="\n".join(Generator.backend_setters_list),
+    fieldDeclarations="\n".join(Generator.backend_field_list),
+    methodNameDeclarations="\n".join(Generator.backend_method_name_declaration_list),
+    methods="\n".join(Generator.backend_method_implementation_list),
+    methodDeclarations="\n".join(Generator.backend_method_declaration_list),
+    messageHandlers="\n".join(Generator.method_handler_list)))
 
 frontend_h_file.write(Templates.frontend_h.substitute(None,
-    fieldDeclarations=join(Generator.frontend_class_field_lines, ""),
-    domainClassList=join(Generator.frontend_domain_class_lines, "")))
+    fieldDeclarations="".join(Generator.frontend_class_field_lines),
+    domainClassList="".join(Generator.frontend_domain_class_lines)))
 
 frontend_cpp_file.write(Templates.frontend_cpp.substitute(None,
-    constructorInit=join(Generator.frontend_constructor_init_list, ""),
-    methods=join(Generator.frontend_method_list, "\n")))
+    constructorInit="".join(Generator.frontend_constructor_init_list),
+    methods="\n".join(Generator.frontend_method_list)))
 
 typebuilder_h_file.write(Templates.typebuilder_h.substitute(None,
-    typeBuilders=join(flatten_list(Generator.type_builder_fragments), ""),
-    forwards=join(Generator.type_builder_forwards, "")))
+    typeBuilders="".join(flatten_list(Generator.type_builder_fragments)),
+    forwards="".join(Generator.type_builder_forwards)))
 
 typebuilder_cpp_file.write(Templates.typebuilder_cpp.substitute(None,
     enumConstantValues=EnumConstants.get_enum_constant_code(),
-    implCode=join(flatten_list(Generator.type_builder_impl_list), ""),
-    validatorCode=join(flatten_list(Generator.validator_impl_list), "")))
+    implCode="".join(flatten_list(Generator.type_builder_impl_list)),
+    validatorCode="".join(flatten_list(Generator.validator_impl_list))))
 
 backend_js_file.write(Templates.backend_js.substitute(None,
-    domainInitializers=join(Generator.backend_js_domain_initializer_list, "")))
+    domainInitializers="".join(Generator.backend_js_domain_initializer_list)))
 
 backend_h_file.close()
 backend_cpp_file.close()

Modified: trunk/Source/WebKit2/ChangeLog (126557 => 126558)


--- trunk/Source/WebKit2/ChangeLog	2012-08-24 08:43:50 UTC (rev 126557)
+++ trunk/Source/WebKit2/ChangeLog	2012-08-24 08:44:24 UTC (rev 126558)
@@ -1,3 +1,17 @@
+2012-08-23  Frederik Gladhorn  <[email protected]>
+
+        Make it possible to build WebKit with Python 3 (and 2)
+        https://bugs.webkit.org/show_bug.cgi?id=94814
+
+        Reviewed by Ryosuke Niwa.
+
+        Exceptions need a hack to work with both.
+        string.join was already deprecated in Python 2.
+        Relative imports are no longer supported, use package name instead.
+
+        * Scripts/webkit2/messages.py:
+        * Scripts/webkit2/parser.py:
+
 2012-08-24  Mark Rowe  <[email protected]>
 
         <http://webkit.org/b/94910> Copy the entire webkit2 module in to the WebKit2 framework wrapper.

Modified: trunk/Source/WebKit2/Scripts/webkit2/messages.py (126557 => 126558)


--- trunk/Source/WebKit2/Scripts/webkit2/messages.py	2012-08-24 08:43:50 UTC (rev 126557)
+++ trunk/Source/WebKit2/Scripts/webkit2/messages.py	2012-08-24 08:44:24 UTC (rev 126558)
@@ -22,10 +22,8 @@
 
 import collections
 import re
+from webkit2 import parser
 
-import parser
-
-
 DELAYED_ATTRIBUTE = 'Delayed'
 DISPATCH_ON_CONNECTION_QUEUE_ATTRIBUTE = 'DispatchOnConnectionQueue'
 

Modified: trunk/Source/WebKit2/Scripts/webkit2/parser.py (126557 => 126558)


--- trunk/Source/WebKit2/Scripts/webkit2/parser.py	2012-08-24 08:43:50 UTC (rev 126557)
+++ trunk/Source/WebKit2/Scripts/webkit2/parser.py	2012-08-24 08:44:24 UTC (rev 126558)
@@ -22,7 +22,7 @@
 
 import re
 
-import model
+from webkit2 import model
 
 
 def parse(file):
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to