Title: [236005] trunk/Source
Revision
236005
Author
[email protected]
Date
2018-09-14 08:16:09 -0700 (Fri, 14 Sep 2018)

Log Message

builtins directory causes name conflict on Python 3
https://bugs.webkit.org/show_bug.cgi?id=189552

Patch by Mike Gorse <[email protected]> on 2018-09-14
Reviewed by Michael Catanzaro.

Source/_javascript_Core:

* CMakeLists.txt: builtins -> wkbuiltins.
* DerivedSources.make: builtins -> wkbuiltins.
* Scripts/generate-js-builtins.py: import wkbuiltins, rather than
  builtins.
* Scripts/wkbuiltins/__init__.py: Renamed from Source/_javascript_Core/Scripts/builtins/__init__.py.
* Scripts/wkbuiltins/builtins_generate_combined_header.py: Renamed from Source/_javascript_Core/Scripts/builtins/builtins_generate_combined_header.py.
* Scripts/wkbuiltins/builtins_generate_internals_wrapper_implementation.py: Renamed from Source/_javascript_Core/Scripts/builtins/builtins_generate_internals_wrapper_implementation.py.
* Scripts/wkbuiltins/builtins_generate_separate_header.py: Renamed from Source/_javascript_Core/Scripts/builtins/builtins_generate_separate_header.py.
* Scripts/wkbuiltins/builtins_generate_separate_implementation.py: Renamed from Source/_javascript_Core/Scripts/builtins/builtins_generate_separate_implementation.py.
* Scripts/wkbuiltins/builtins_generate_wrapper_header.py: Renamed from Source/_javascript_Core/Scripts/builtins/builtins_generate_wrapper_header.py.
* Scripts/wkbuiltins/builtins_generate_wrapper_implementation.py: Renamed from Source/_javascript_Core/Scripts/builtins/builtins_generate_wrapper_implementation.py.
* Scripts/wkbuiltins/builtins_generator.py: Renamed from Source/_javascript_Core/Scripts/builtins/builtins_generator.py.
* Scripts/wkbuiltins/builtins_model.py: Renamed from Source/_javascript_Core/Scripts/builtins/builtins_model.py.
* Scripts/wkbuiltins/builtins_templates.py: Renamed from Source/_javascript_Core/Scripts/builtins/builtins_templates.py.
* Scripts/wkbuiltins/wkbuiltins.py: Renamed from Source/_javascript_Core/Scripts/builtins/builtins.py.
* _javascript_Core.xcodeproj/project.pbxproj: Update for the renaming.

Source/WebCore:

No new tests (No behavior change).

* CMakeLists.txt: builtins -> wkbuiltins.
* DerivedSources.make: builtins -> wkbuiltins.

Modified Paths

Added Paths

Removed Paths

  • trunk/Source/_javascript_Core/Scripts/builtins/

Diff

Modified: trunk/Source/_javascript_Core/CMakeLists.txt (236004 => 236005)


--- trunk/Source/_javascript_Core/CMakeLists.txt	2018-09-14 11:01:06 UTC (rev 236004)
+++ trunk/Source/_javascript_Core/CMakeLists.txt	2018-09-14 15:16:09 UTC (rev 236005)
@@ -136,7 +136,8 @@
 set(_javascript_Core_SCRIPTS_SOURCES_PATHS
     ${_javascript_Core_SCRIPTS_SOURCES_DIR}/*.pl
     ${_javascript_Core_SCRIPTS_SOURCES_DIR}/*.py
-    ${_javascript_Core_SCRIPTS_SOURCES_DIR}/builtins/builtins*.py
+    ${_javascript_Core_SCRIPTS_SOURCES_DIR}/wkbuiltins/builtins*.py
+    ${_javascript_Core_SCRIPTS_SOURCES_DIR}/wkbuiltins/wkbuiltins.py
 )
 
 # Force _javascript_Core to run scripts from the same staging path as WebCore.
@@ -1088,7 +1089,7 @@
 # JSCBuiltins
 
 set(BUILTINS_GENERATOR_SCRIPTS
-    ${_javascript_Core_SCRIPTS_DIR}/builtins.py
+    ${_javascript_Core_SCRIPTS_DIR}/wkbuiltins.py
     ${_javascript_Core_SCRIPTS_DIR}/builtins_generator.py
     ${_javascript_Core_SCRIPTS_DIR}/builtins_model.py
     ${_javascript_Core_SCRIPTS_DIR}/builtins_templates.py

Modified: trunk/Source/_javascript_Core/ChangeLog (236004 => 236005)


--- trunk/Source/_javascript_Core/ChangeLog	2018-09-14 11:01:06 UTC (rev 236004)
+++ trunk/Source/_javascript_Core/ChangeLog	2018-09-14 15:16:09 UTC (rev 236005)
@@ -1,3 +1,27 @@
+2018-09-14  Mike Gorse  <[email protected]>
+
+        builtins directory causes name conflict on Python 3
+        https://bugs.webkit.org/show_bug.cgi?id=189552
+
+        Reviewed by Michael Catanzaro.
+
+        * CMakeLists.txt: builtins -> wkbuiltins.
+        * DerivedSources.make: builtins -> wkbuiltins.
+        * Scripts/generate-js-builtins.py: import wkbuiltins, rather than
+          builtins.
+        * Scripts/wkbuiltins/__init__.py: Renamed from Source/_javascript_Core/Scripts/builtins/__init__.py.
+        * Scripts/wkbuiltins/builtins_generate_combined_header.py: Renamed from Source/_javascript_Core/Scripts/builtins/builtins_generate_combined_header.py.
+        * Scripts/wkbuiltins/builtins_generate_internals_wrapper_implementation.py: Renamed from Source/_javascript_Core/Scripts/builtins/builtins_generate_internals_wrapper_implementation.py.
+        * Scripts/wkbuiltins/builtins_generate_separate_header.py: Renamed from Source/_javascript_Core/Scripts/builtins/builtins_generate_separate_header.py.
+        * Scripts/wkbuiltins/builtins_generate_separate_implementation.py: Renamed from Source/_javascript_Core/Scripts/builtins/builtins_generate_separate_implementation.py.
+        * Scripts/wkbuiltins/builtins_generate_wrapper_header.py: Renamed from Source/_javascript_Core/Scripts/builtins/builtins_generate_wrapper_header.py.
+        * Scripts/wkbuiltins/builtins_generate_wrapper_implementation.py: Renamed from Source/_javascript_Core/Scripts/builtins/builtins_generate_wrapper_implementation.py.
+        * Scripts/wkbuiltins/builtins_generator.py: Renamed from Source/_javascript_Core/Scripts/builtins/builtins_generator.py.
+        * Scripts/wkbuiltins/builtins_model.py: Renamed from Source/_javascript_Core/Scripts/builtins/builtins_model.py.
+        * Scripts/wkbuiltins/builtins_templates.py: Renamed from Source/_javascript_Core/Scripts/builtins/builtins_templates.py.
+        * Scripts/wkbuiltins/wkbuiltins.py: Renamed from Source/_javascript_Core/Scripts/builtins/builtins.py.
+        * _javascript_Core.xcodeproj/project.pbxproj: Update for the renaming.
+
 2018-09-13  Yusuke Suzuki  <[email protected]>
 
         [WebAssembly] Inline WasmContext accessor functions

Modified: trunk/Source/_javascript_Core/DerivedSources.make (236004 => 236005)


--- trunk/Source/_javascript_Core/DerivedSources.make	2018-09-14 11:01:06 UTC (rev 236004)
+++ trunk/Source/_javascript_Core/DerivedSources.make	2018-09-14 15:16:09 UTC (rev 236005)
@@ -73,19 +73,19 @@
 # _javascript_ builtins.
 
 BUILTINS_GENERATOR_SCRIPTS = \
-    $(_javascript_Core_SCRIPTS_DIR)/builtins/__init__.py \
-    $(_javascript_Core_SCRIPTS_DIR)/builtins/builtins.py \
-    $(_javascript_Core_SCRIPTS_DIR)/builtins/builtins_generator.py \
-    $(_javascript_Core_SCRIPTS_DIR)/builtins/builtins_model.py \
-    $(_javascript_Core_SCRIPTS_DIR)/builtins/builtins_templates.py \
-    $(_javascript_Core_SCRIPTS_DIR)/builtins/builtins_generate_combined_header.py \
-    $(_javascript_Core_SCRIPTS_DIR)/builtins/builtins_generate_combined_implementation.py \
-    $(_javascript_Core_SCRIPTS_DIR)/builtins/builtins_generate_separate_header.py \
-    $(_javascript_Core_SCRIPTS_DIR)/builtins/builtins_generate_separate_implementation.py \
-    ${_javascript_Core_SCRIPTS_DIR}/builtins/builtins_generate_wrapper_header.py \
-    ${_javascript_Core_SCRIPTS_DIR}/builtins/builtins_generate_wrapper_implementation.py \
-    ${_javascript_Core_SCRIPTS_DIR}/builtins/builtins_generate_internals_wrapper_header.py \
-    ${_javascript_Core_SCRIPTS_DIR}/builtins/builtins_generate_internals_wrapper_implementation.py \
+    $(_javascript_Core_SCRIPTS_DIR)/wkbuiltins/__init__.py \
+    $(_javascript_Core_SCRIPTS_DIR)/wkbuiltins/wkbuiltins.py \
+    $(_javascript_Core_SCRIPTS_DIR)/wkbuiltins/builtins_generator.py \
+    $(_javascript_Core_SCRIPTS_DIR)/wkbuiltins/builtins_model.py \
+    $(_javascript_Core_SCRIPTS_DIR)/wkbuiltins/builtins_templates.py \
+    $(_javascript_Core_SCRIPTS_DIR)/wkbuiltins/builtins_generate_combined_header.py \
+    $(_javascript_Core_SCRIPTS_DIR)/wkbuiltins/builtins_generate_combined_implementation.py \
+    $(_javascript_Core_SCRIPTS_DIR)/wkbuiltins/builtins_generate_separate_header.py \
+    $(_javascript_Core_SCRIPTS_DIR)/wkbuiltins/builtins_generate_separate_implementation.py \
+    ${_javascript_Core_SCRIPTS_DIR}/wkbuiltins/builtins_generate_wrapper_header.py \
+    ${_javascript_Core_SCRIPTS_DIR}/wkbuiltins/builtins_generate_wrapper_implementation.py \
+    ${_javascript_Core_SCRIPTS_DIR}/wkbuiltins/builtins_generate_internals_wrapper_header.py \
+    ${_javascript_Core_SCRIPTS_DIR}/wkbuiltins/builtins_generate_internals_wrapper_implementation.py \
     $(_javascript_Core_SCRIPTS_DIR)/generate-js-builtins.py \
     $(_javascript_Core_SCRIPTS_DIR)/lazywriter.py \
 #

Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (236004 => 236005)


--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2018-09-14 11:01:06 UTC (rev 236004)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2018-09-14 15:16:09 UTC (rev 236005)
@@ -1274,7 +1274,7 @@
 		99DA00A31BD5993100F4575C /* builtins_generator.py in Headers */ = {isa = PBXBuildFile; fileRef = 99DA009A1BD5992700F4575C /* builtins_generator.py */; settings = {ATTRIBUTES = (Private, ); }; };
 		99DA00A41BD5993100F4575C /* builtins_model.py in Headers */ = {isa = PBXBuildFile; fileRef = 99DA009B1BD5992700F4575C /* builtins_model.py */; settings = {ATTRIBUTES = (Private, ); }; };
 		99DA00A51BD5993100F4575C /* builtins_templates.py in Headers */ = {isa = PBXBuildFile; fileRef = 99DA009C1BD5992700F4575C /* builtins_templates.py */; settings = {ATTRIBUTES = (Private, ); }; };
-		99DA00A61BD5993100F4575C /* builtins.py in Headers */ = {isa = PBXBuildFile; fileRef = 99DA009D1BD5992700F4575C /* builtins.py */; settings = {ATTRIBUTES = (Private, ); }; };
+		99DA00A61BD5993100F4575C /* wkbuiltins.py in Headers */ = {isa = PBXBuildFile; fileRef = 99DA009D1BD5992700F4575C /* wkbuiltins.py */; settings = {ATTRIBUTES = (Private, ); }; };
 		99DA00A71BD5993100F4575C /* builtins_generate_combined_header.py in Headers */ = {isa = PBXBuildFile; fileRef = 99DA009E1BD5992700F4575C /* builtins_generate_combined_header.py */; settings = {ATTRIBUTES = (Private, ); }; };
 		99DA00A81BD5993100F4575C /* builtins_generate_combined_implementation.py in Headers */ = {isa = PBXBuildFile; fileRef = 99DA009F1BD5992700F4575C /* builtins_generate_combined_implementation.py */; settings = {ATTRIBUTES = (Private, ); }; };
 		99DA00A91BD5993100F4575C /* builtins_generate_separate_header.py in Headers */ = {isa = PBXBuildFile; fileRef = 99DA00A01BD5992700F4575C /* builtins_generate_separate_header.py */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -3948,7 +3948,7 @@
 		99DA009A1BD5992700F4575C /* builtins_generator.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = builtins_generator.py; sourceTree = "<group>"; };
 		99DA009B1BD5992700F4575C /* builtins_model.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = builtins_model.py; sourceTree = "<group>"; };
 		99DA009C1BD5992700F4575C /* builtins_templates.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = builtins_templates.py; sourceTree = "<group>"; };
-		99DA009D1BD5992700F4575C /* builtins.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = builtins.py; sourceTree = "<group>"; };
+		99DA009D1BD5992700F4575C /* wkbuiltins.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = wkbuiltins.py; sourceTree = "<group>"; };
 		99DA009E1BD5992700F4575C /* builtins_generate_combined_header.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = builtins_generate_combined_header.py; sourceTree = "<group>"; };
 		99DA009F1BD5992700F4575C /* builtins_generate_combined_implementation.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = builtins_generate_combined_implementation.py; sourceTree = "<group>"; };
 		99DA00A01BD5992700F4575C /* builtins_generate_separate_header.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = builtins_generate_separate_header.py; sourceTree = "<group>"; };
@@ -7826,11 +7826,11 @@
 			path = Scripts;
 			sourceTree = "<group>";
 		};
-		99DA00971BD598E000F4575C /* builtins */ = {
+		99DA00971BD598E000F4575C /* wkbuiltins */ = {
 			isa = PBXGroup;
 			children = (
 				99DA00991BD5992700F4575C /* __init__.py */,
-				99DA009D1BD5992700F4575C /* builtins.py */,
+				99DA009D1BD5992700F4575C /* wkbuiltins.py */,
 				99DA009E1BD5992700F4575C /* builtins_generate_combined_header.py */,
 				99DA009F1BD5992700F4575C /* builtins_generate_combined_implementation.py */,
 				412952731D2CF6AC00E78B89 /* builtins_generate_internals_wrapper_header.py */,
@@ -7843,7 +7843,7 @@
 				99DA009B1BD5992700F4575C /* builtins_model.py */,
 				99DA009C1BD5992700F4575C /* builtins_templates.py */,
 			);
-			path = builtins;
+			path = wkbuiltins;
 			sourceTree = "<group>";
 		};
 		A513E5CC185FB992007E95AD /* agents */ = {
@@ -8439,7 +8439,7 @@
 				DE26E9031CB5DD0500D2BE82 /* BuiltinExecutableCreator.h in Headers */,
 				A7D801A51880D66E0026C39B /* BuiltinExecutables.h in Headers */,
 				A75EE9B218AAB7E200AAD043 /* BuiltinNames.h in Headers */,
-				99DA00A61BD5993100F4575C /* builtins.py in Headers */,
+				99DA00A61BD5993100F4575C /* wkbuiltins.py in Headers */,
 				99DA00A71BD5993100F4575C /* builtins_generate_combined_header.py in Headers */,
 				99DA00A81BD5993100F4575C /* builtins_generate_combined_implementation.py in Headers */,
 				412952771D2CF6BC00E78B89 /* builtins_generate_internals_wrapper_header.py in Headers */,

Modified: trunk/Source/_javascript_Core/Scripts/generate-js-builtins.py (236004 => 236005)


--- trunk/Source/_javascript_Core/Scripts/generate-js-builtins.py	2018-09-14 11:01:06 UTC (rev 236004)
+++ trunk/Source/_javascript_Core/Scripts/generate-js-builtins.py	2018-09-14 15:16:09 UTC (rev 236005)
@@ -37,7 +37,7 @@
 
 from lazywriter import LazyFileWriter
 
-from builtins import *
+from wkbuiltins import *
 
 
 def concatenated_output_filename(builtins_files, framework_name, generate_only_wrapper_files):

Copied: trunk/Source/_javascript_Core/Scripts/wkbuiltins/__init__.py (from rev 236004, trunk/Source/_javascript_Core/Scripts/builtins/__init__.py) (0 => 236005)


--- trunk/Source/_javascript_Core/Scripts/wkbuiltins/__init__.py	                        (rev 0)
+++ trunk/Source/_javascript_Core/Scripts/wkbuiltins/__init__.py	2018-09-14 15:16:09 UTC (rev 236005)
@@ -0,0 +1,3 @@
+# Required for Python to search this directory for module files
+
+from wkbuiltins import *

Copied: trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generate_combined_header.py (from rev 236004, trunk/Source/_javascript_Core/Scripts/builtins/builtins_generate_combined_header.py) (0 => 236005)


--- trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generate_combined_header.py	                        (rev 0)
+++ trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generate_combined_header.py	2018-09-14 15:16:09 UTC (rev 236005)
@@ -0,0 +1,171 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2014-2016 Apple Inc. All rights reserved.
+# Copyright (c) 2014 University of Washington. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# THE POSSIBILITY OF SUCH DAMAGE.
+
+
+import logging
+import re
+import string
+from string import Template
+
+from builtins_generator import BuiltinsGenerator
+from builtins_templates import BuiltinsGeneratorTemplates as Templates
+
+log = logging.getLogger('global')
+
+
+class BuiltinsCombinedHeaderGenerator(BuiltinsGenerator):
+    def __init__(self, model):
+        BuiltinsGenerator.__init__(self, model)
+
+    def output_filename(self):
+        return "%sBuiltins.h" % self.model().framework.setting('namespace')
+
+    def generate_output(self):
+        args = {
+            'namespace': self.model().framework.setting('namespace'),
+            'macroPrefix': self.model().framework.setting('macro_prefix'),
+        }
+
+        sections = []
+        sections.append(self.generate_license())
+        sections.append(Template(Templates.DoNotEditWarning).substitute(args))
+        sections.append(Template(Templates.HeaderIncludeGuard).substitute(args))
+        sections.append(self.generate_forward_declarations())
+        sections.append(Template(Templates.NamespaceTop).substitute(args))
+        for object in self.model().objects:
+            sections.append(self.generate_section_for_object(object))
+        sections.append(self.generate_section_for_code_table_macro())
+        sections.append(self.generate_section_for_code_name_macro())
+        sections.append(self.generate_section_for_global_private_code_name_macro())
+        sections.append(Template(Templates.CombinedHeaderStaticMacros).substitute(args))
+        sections.append(Template(Templates.NamespaceBottom).substitute(args))
+
+        return "\n\n".join(sections)
+
+    def generate_forward_declarations(self):
+        return """namespace JSC {
+class FunctionExecutable;
+class VM;
+
+enum class ConstructAbility : unsigned;
+}"""
+
+    def generate_section_for_object(self, object):
+        lines = []
+        lines.append('/* %s */' % object.object_name)
+        lines.extend(self.generate_externs_for_object(object))
+        lines.append("")
+        lines.extend(self.generate_macros_for_object(object))
+        return '\n'.join(lines)
+
+    def generate_externs_for_object(self, object):
+        lines = []
+
+        for function in object.functions:
+            function_args = {
+                'codeName': BuiltinsGenerator.mangledNameForFunction(function) + 'Code',
+            }
+
+            lines.append("""extern const char* s_%(codeName)s;
+extern const int s_%(codeName)sLength;
+extern const JSC::ConstructAbility s_%(codeName)sConstructAbility;""" % function_args)
+
+        return lines
+
+    def generate_macros_for_object(self, object):
+        args = {
+            'macroPrefix': self.model().framework.setting('macro_prefix'),
+            'objectMacro': object.object_name.replace('.', '').upper(),
+        }
+
+        lines = []
+        lines.append("#define %(macroPrefix)s_FOREACH_%(objectMacro)s_BUILTIN_DATA(macro) \\" % args)
+        for function in object.functions:
+            function_args = {
+                'funcName': function.function_name,
+                'mangledName': BuiltinsGenerator.mangledNameForFunction(function),
+                'paramCount': len(function.parameters),
+            }
+
+            lines.append("    macro(%(funcName)s, %(mangledName)s, %(paramCount)d) \\" % function_args)
+        return lines
+
+    def generate_section_for_code_table_macro(self):
+        args = {
+            'macroPrefix': self.model().framework.setting('macro_prefix'),
+        }
+
+        lines = []
+        lines.append("#define %(macroPrefix)s_FOREACH_BUILTIN_CODE(macro) \\" % args)
+        for function in self.model().all_functions():
+            function_args = {
+                'funcName': function.function_name,
+                'overriddenName': function.overridden_name,
+                'codeName': BuiltinsGenerator.mangledNameForFunction(function) + 'Code',
+            }
+
+            lines.append("    macro(%(codeName)s, %(funcName)s, %(overriddenName)s, s_%(codeName)sLength) \\" % function_args)
+        return '\n'.join(lines)
+
+    def generate_section_for_code_name_macro(self):
+        args = {
+            'macroPrefix': self.model().framework.setting('macro_prefix'),
+        }
+
+        internal_function_names = [function.function_name for function in self.model().all_internal_functions()]
+        if len(internal_function_names) != len(set(internal_function_names)):
+            log.error("There are several internal functions with the same name. Private identifiers may clash.")
+
+        lines = []
+        lines.append("#define %(macroPrefix)s_FOREACH_BUILTIN_FUNCTION_NAME(macro) \\" % args)
+        unique_names = list(set([function.function_name for function in self.model().all_functions()]))
+        unique_names.sort()
+        for function_name in unique_names:
+            function_args = {
+                'funcName': function_name,
+            }
+
+            lines.append("    macro(%(funcName)s) \\" % function_args)
+        return '\n'.join(lines)
+
+    def generate_section_for_global_private_code_name_macro(self):
+        args = {
+            'macroPrefix': self.model().framework.setting('macro_prefix'),
+        }
+
+        lines = []
+        lines.append("#define %(macroPrefix)s_FOREACH_BUILTIN_FUNCTION_PRIVATE_GLOBAL_NAME(macro) \\" % args)
+        functions = filter(lambda function: function.is_global_private, self.model().all_functions())
+        functions.sort(key=lambda x: x.function_name)
+        for function in functions:
+            function_args = {
+                'funcName': function.function_name,
+                'codeName': BuiltinsGenerator.mangledNameForFunction(function),
+            }
+
+            lines.append("    macro(%(funcName)s, %(codeName)s) \\" % function_args)
+
+        return '\n'.join(lines)

Copied: trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generate_combined_implementation.py (from rev 236004, trunk/Source/_javascript_Core/Scripts/builtins/builtins_generate_combined_implementation.py) (0 => 236005)


--- trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generate_combined_implementation.py	                        (rev 0)
+++ trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generate_combined_implementation.py	2018-09-14 15:16:09 UTC (rev 236005)
@@ -0,0 +1,100 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2014, 2015 Apple Inc. All rights reserved.
+# Copyright (c) 2014 University of Washington. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# THE POSSIBILITY OF SUCH DAMAGE.
+
+
+import logging
+import re
+import string
+from string import Template
+
+from builtins_generator import BuiltinsGenerator
+from builtins_model import Framework, Frameworks
+from builtins_templates import BuiltinsGeneratorTemplates as Templates
+
+log = logging.getLogger('global')
+
+
+class BuiltinsCombinedImplementationGenerator(BuiltinsGenerator):
+    def __init__(self, model):
+        BuiltinsGenerator.__init__(self, model)
+
+    def output_filename(self):
+        return "%sBuiltins.cpp" % self.model().framework.setting('namespace')
+
+    def generate_output(self):
+        args = {
+            'namespace': self.model().framework.setting('namespace'),
+            'macroPrefix': self.model().framework.setting('macro_prefix'),
+        }
+
+        sections = []
+        sections.append(self.generate_license())
+        sections.append(Template(Templates.DoNotEditWarning).substitute(args))
+        sections.append(self.generate_primary_header_includes())
+        sections.append(self.generate_secondary_header_includes())
+        sections.append(Template(Templates.NamespaceTop).substitute(args))
+        for function in self.model().all_functions():
+            sections.append(self.generate_embedded_code_string_section_for_function(function))
+        if self.model().framework is Frameworks._javascript_Core:
+            sections.append(Template(Templates.CombinedJSCImplementationStaticMacros).substitute(args))
+        elif self.model().framework is Frameworks.WebCore:
+            sections.append(Template(Templates.CombinedWebCoreImplementationStaticMacros).substitute(args))
+        sections.append(Template(Templates.NamespaceBottom).substitute(args))
+
+        return "\n\n".join(sections)
+
+    def generate_secondary_header_includes(self):
+        header_includes = [
+            (["_javascript_Core"],
+                ("_javascript_Core", "builtins/BuiltinExecutables.h"),
+            ),
+            (["_javascript_Core", "WebCore"],
+                ("_javascript_Core", "heap/HeapInlines.h"),
+            ),
+            (["_javascript_Core", "WebCore"],
+                ("_javascript_Core", "runtime/UnlinkedFunctionExecutable.h"),
+            ),
+            (["_javascript_Core", "WebCore"],
+                ("_javascript_Core", "runtime/JSCellInlines.h"),
+            ),
+            (["WebCore"],
+                ("_javascript_Core", "runtime/StructureInlines.h"),
+            ),
+            (["WebCore"],
+                ("_javascript_Core", "runtime/JSCJSValueInlines.h"),
+            ),
+            (["_javascript_Core", "WebCore"],
+                ("_javascript_Core", "runtime/VM.h"),
+            ),
+            (["_javascript_Core", "WebCore"],
+                ("_javascript_Core", "runtime/IdentifierInlines.h"),
+            ),
+            (["_javascript_Core", "WebCore"],
+                ("_javascript_Core", "runtime/Intrinsic.h"),
+            ),
+        ]
+
+        return '\n'.join(self.generate_includes_from_entries(header_includes))

Copied: trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generate_internals_wrapper_header.py (from rev 236004, trunk/Source/_javascript_Core/Scripts/builtins/builtins_generate_internals_wrapper_header.py) (0 => 236005)


--- trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generate_internals_wrapper_header.py	                        (rev 0)
+++ trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generate_internals_wrapper_header.py	2018-09-14 15:16:09 UTC (rev 236005)
@@ -0,0 +1,113 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2016 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# THE POSSIBILITY OF SUCH DAMAGE.
+
+
+import logging
+from string import Template
+
+from builtins_generator import BuiltinsGenerator, WK_lcfirst, WK_ucfirst
+from builtins_templates import BuiltinsGeneratorTemplates as Templates
+
+log = logging.getLogger('global')
+
+
+class BuiltinsInternalsWrapperHeaderGenerator(BuiltinsGenerator):
+    def __init__(self, model):
+        BuiltinsGenerator.__init__(self, model)
+        self.internals = filter(lambda object: 'internal' in object.annotations, model.objects)
+
+    def output_filename(self):
+        return "%sJSBuiltinInternals.h" % self.model().framework.setting('namespace')
+
+    def generate_output(self):
+        args = {
+            'namespace': self.model().framework.setting('namespace'),
+        }
+
+        sections = []
+        sections.append(self.generate_license())
+        sections.append(Template(Templates.DoNotEditWarning).substitute(args))
+        sections.append(Template(Templates.HeaderIncludeGuard).substitute(args))
+        sections.append(self.generate_secondary_header_includes())
+
+        sections.append(Template(Templates.NamespaceTop).substitute(args))
+        sections.append(self.generate_section_for_object())
+        sections.append(Template(Templates.NamespaceBottom).substitute(args))
+
+        return "\n\n".join(sections)
+
+    def generate_secondary_header_includes(self):
+        header_includes = [
+            (["WebCore"], ("_javascript_Core", "heap/WeakInlines.h")),
+            (["WebCore"], ("_javascript_Core", "runtime/VM.h"))
+        ]
+        for object in self.internals:
+            header_includes.append((["WebCore"], ("WebCore", object.object_name + "Builtins.h")))
+
+        return '\n'.join(self.generate_includes_from_entries(header_includes))
+
+    def generate_section_for_object(self):
+        lines = ["class JSDOMGlobalObject;",
+                 "",
+                 "class JSBuiltinInternalFunctions {",
+                 "public:"]
+
+        lines.append("    explicit JSBuiltinInternalFunctions(JSC::VM&);")
+        lines.append(self.generate_methods())
+        lines.append(self.generate_accessors())
+        lines.append("private:")
+        lines.append(self.generate_members())
+        lines.append("};")
+        return '\n'.join(lines)
+
+    def accessor_name(self, object):
+        return WK_lcfirst(object.object_name)
+
+    def member_name(self, object):
+        return "m_" + self.accessor_name(object)
+
+    def member_type(self, object):
+        return WK_ucfirst(object.object_name) + "BuiltinFunctions"
+
+    def generate_methods(self):
+        return """
+    void visit(JSC::SlotVisitor&);
+    void initialize(JSDOMGlobalObject&);
+"""
+
+    def generate_accessors(self):
+        lines = []
+        for object in self.internals:
+            accessor = "    %s& %s() { return %s; }" % (self.member_type(object), self.accessor_name(object), self.member_name(object))
+            lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), accessor))
+        lines.append("")
+        return '\n'.join(lines)
+
+    def generate_members(self):
+        lines = ["    JSC::VM& m_vm;"]
+        for object in self.internals:
+            member = "    %s %s;" % (self.member_type(object), self.member_name(object))
+            lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), member))
+        return '\n'.join(lines)

Copied: trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generate_internals_wrapper_implementation.py (from rev 236004, trunk/Source/_javascript_Core/Scripts/builtins/builtins_generate_internals_wrapper_implementation.py) (0 => 236005)


--- trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generate_internals_wrapper_implementation.py	                        (rev 0)
+++ trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generate_internals_wrapper_implementation.py	2018-09-14 15:16:09 UTC (rev 236005)
@@ -0,0 +1,156 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2016 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# THE POSSIBILITY OF SUCH DAMAGE.
+
+
+import logging
+from string import Template
+
+from builtins_generator import BuiltinsGenerator, WK_lcfirst, WK_ucfirst
+from builtins_templates import BuiltinsGeneratorTemplates as Templates
+
+log = logging.getLogger('global')
+
+
+class BuiltinsInternalsWrapperImplementationGenerator(BuiltinsGenerator):
+    def __init__(self, model):
+        BuiltinsGenerator.__init__(self, model)
+        self.internals = filter(lambda object: 'internal' in object.annotations, model.objects)
+
+    def output_filename(self):
+        return "%sJSBuiltinInternals.cpp" % self.model().framework.setting('namespace')
+
+    def generate_output(self):
+        args = {
+            'namespace': self.model().framework.setting('namespace'),
+        }
+
+        sections = []
+        sections.append(self.generate_license())
+        sections.append(Template(Templates.DoNotEditWarning).substitute(args))
+        sections.append(self.generate_primary_header_includes())
+        sections.append(self.generate_secondary_header_includes())
+
+        sections.append(Template(Templates.NamespaceTop).substitute(args))
+        sections.append(self.generate_section_for_object())
+        sections.append(Template(Templates.NamespaceBottom).substitute(args))
+
+        return "\n\n".join(sections)
+
+    def generate_secondary_header_includes(self):
+        header_includes = [
+            (["WebCore"],
+                ("WebCore", "JSDOMGlobalObject.h"),
+            ),
+            (["WebCore"],
+                ("WebCore", "WebCoreJSClientData.h"),
+            ),
+            (["WebCore"],
+                ("_javascript_Core", "heap/HeapInlines.h"),
+            ),
+            (["WebCore"],
+                ("_javascript_Core", "heap/SlotVisitorInlines.h"),
+            ),
+            (["WebCore"],
+                ("_javascript_Core", "runtime/JSCJSValueInlines.h"),
+            ),
+            (["WebCore"],
+                ("_javascript_Core", "runtime/StructureInlines.h"),
+            ),
+        ]
+        return '\n'.join(self.generate_includes_from_entries(header_includes))
+
+    def generate_section_for_object(self):
+        lines = []
+
+        lines.append(self.generate_constructor())
+        lines.append(self.generate_visit_method())
+        lines.append(self.generate_initialize_method())
+        return '\n'.join(lines)
+
+    def accessor_name(self, object):
+        return WK_lcfirst(object.object_name)
+
+    def member_name(self, object):
+        return "m_" + self.accessor_name(object)
+
+    def member_type(self, object):
+        return WK_ucfirst(object.object_name) + "BuiltinFunctions"
+
+    def generate_constructor(self):
+        guards = set([object.annotations.get('conditional') for object in self.internals if 'conditional' in object.annotations])
+        lines = ["JSBuiltinInternalFunctions::JSBuiltinInternalFunctions(JSC::VM& vm)",
+                 "    : m_vm(vm)"]
+        for object in self.internals:
+            initializer = "    , %s(m_vm)" % self.member_name(object)
+            lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), initializer))
+        lines.append("{")
+        lines.append("    UNUSED_PARAM(vm);")
+        lines.append("}\n")
+        return '\n'.join(lines)
+
+    def property_macro(self, object):
+        lines = []
+        lines.append("#define DECLARE_GLOBAL_STATIC(name) \\")
+        lines.append("    JSDOMGlobalObject::GlobalPropertyInfo( \\")
+        lines.append("        clientData.builtinFunctions().%sBuiltins().name##PrivateName(), %s().m_##name##Function.get() , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly)," % (self.accessor_name(object), self.accessor_name(object)))
+        lines.append("    WEBCORE_FOREACH_%s_BUILTIN_FUNCTION_NAME(DECLARE_GLOBAL_STATIC)" % object.object_name.upper())
+        lines.append("#undef DECLARE_GLOBAL_STATIC")
+        return '\n'.join(lines)
+
+    def generate_visit_method(self):
+        lines = ["void JSBuiltinInternalFunctions::visit(JSC::SlotVisitor& visitor)",
+                 "{"]
+        for object in self.internals:
+            visit = "    %s.visit(visitor);" % self.member_name(object)
+            lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), visit))
+        lines.append("    UNUSED_PARAM(visitor);")
+        lines.append("}\n")
+        return '\n'.join(lines)
+
+    def _generate_initialize_static_globals(self):
+        lines = ["    JSVMClientData& clientData = *static_cast<JSVMClientData*>(m_vm.clientData);",
+                 "    JSDOMGlobalObject::GlobalPropertyInfo staticGlobals[] = {"]
+        for object in self.internals:
+            lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), self.property_macro(object)))
+        lines.append("    };")
+        lines.append("    globalObject.addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals));")
+        lines.append("    UNUSED_PARAM(clientData);")
+        return '\n'.join(lines)
+
+    def generate_initialize_method(self):
+        lines = ["void JSBuiltinInternalFunctions::initialize(JSDOMGlobalObject& globalObject)",
+                "{",
+                "    UNUSED_PARAM(globalObject);"]
+
+        for object in self.internals:
+            init = "    %s.init(globalObject);" % self.member_name(object)
+            lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), init))
+        lines.append("")
+
+        guards = set([object.annotations.get('conditional') for object in self.internals if 'conditional' in object.annotations])
+        lines.append(BuiltinsGenerator.wrap_with_guard(" || ".join(guards), self._generate_initialize_static_globals()))
+
+        lines.append("}")
+        return '\n'.join(lines)

Copied: trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generate_separate_header.py (from rev 236004, trunk/Source/_javascript_Core/Scripts/builtins/builtins_generate_separate_header.py) (0 => 236005)


--- trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generate_separate_header.py	                        (rev 0)
+++ trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generate_separate_header.py	2018-09-14 15:16:09 UTC (rev 236005)
@@ -0,0 +1,198 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2014, 2015 Apple Inc. All rights reserved.
+# Copyright (c) 2014 University of Washington. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# THE POSSIBILITY OF SUCH DAMAGE.
+
+
+import logging
+import re
+import string
+from string import Template
+
+from builtins_generator import BuiltinsGenerator
+from builtins_model import Frameworks
+from builtins_templates import BuiltinsGeneratorTemplates as Templates
+
+log = logging.getLogger('global')
+
+
+class BuiltinsSeparateHeaderGenerator(BuiltinsGenerator):
+    def __init__(self, model, object):
+        BuiltinsGenerator.__init__(self, model)
+        self.object = object
+
+    def output_filename(self):
+        return "%sBuiltins.h" % BuiltinsGenerator.mangledNameForObject(self.object)
+
+    def macro_prefix(self):
+        return self.model().framework.setting('macro_prefix')
+
+    def generate_output(self):
+        args = {
+            'namespace': self.model().framework.setting('namespace'),
+            'macroPrefix': self.macro_prefix(),
+            'objectName': self.object.object_name,
+            'objectMacro': self.object.object_name.upper(),
+        }
+
+        conditional_guard = self.object.annotations.get('conditional')
+
+        sections = []
+        sections.append(self.generate_license())
+        sections.append(Template(Templates.DoNotEditWarning).substitute(args))
+        sections.append(Template(Templates.HeaderIncludeGuard).substitute(args))
+        if conditional_guard is not None:
+            sections.append("#if %s" % conditional_guard)
+        sections.append(self.generate_secondary_header_includes())
+        sections.append(self.generate_forward_declarations())
+        sections.append(Template(Templates.NamespaceTop).substitute(args))
+        sections.append(self.generate_section_for_object(self.object))
+        sections.append(self.generate_section_for_code_table_macro())
+        sections.append(self.generate_section_for_code_name_macro())
+        sections.append(Template(Templates.SeparateHeaderStaticMacros).substitute(args))
+        if self.model().framework is Frameworks.WebCore:
+            sections.append(Template(Templates.SeparateHeaderWrapperBoilerplate).substitute(args))
+            if self.object.annotations.get('internal'):
+                sections.append(Template(Templates.SeparateHeaderInternalFunctionsBoilerplate).substitute(args))
+        sections.append(Template(Templates.NamespaceBottom).substitute(args))
+        if conditional_guard is not None:
+            sections.append("#endif // %s" % conditional_guard)
+
+        return "\n\n".join(sections)
+
+    def generate_forward_declarations(self):
+        return """namespace JSC {
+class FunctionExecutable;
+}"""
+
+    def generate_secondary_header_includes(self):
+        header_includes = [
+            (["WebCore"],
+                ("_javascript_Core", "bytecode/UnlinkedFunctionExecutable.h"),
+            ),
+
+            (["WebCore"],
+                ("_javascript_Core", "builtins/BuiltinUtils.h"),
+            ),
+
+            (["WebCore"],
+                ("_javascript_Core", "runtime/Identifier.h"),
+            ),
+
+            (["WebCore"],
+                ("_javascript_Core", "runtime/JSFunction.h"),
+            ),
+        ]
+
+        return '\n'.join(self.generate_includes_from_entries(header_includes))
+
+    def generate_section_for_object(self, object):
+        lines = []
+        lines.append('/* %s */' % object.object_name)
+        lines.extend(self.generate_externs_for_object(object))
+        lines.append("")
+        lines.extend(self.generate_macros_for_object(object))
+        lines.append("")
+        lines.extend(self.generate_defines_for_object(object))
+        return '\n'.join(lines)
+
+    def generate_externs_for_object(self, object):
+        lines = []
+
+        for function in object.functions:
+            function_args = {
+                'codeName': BuiltinsGenerator.mangledNameForFunction(function) + 'Code',
+            }
+
+            lines.append("""extern const char* s_%(codeName)s;
+extern const int s_%(codeName)sLength;
+extern const JSC::ConstructAbility s_%(codeName)sConstructAbility;""" % function_args)
+
+        return lines
+
+    def generate_macros_for_object(self, object):
+        args = {
+            'macroPrefix': self.macro_prefix(),
+            'objectMacro': object.object_name.replace('.', '_').upper(),
+        }
+
+        lines = []
+        lines.append("#define %(macroPrefix)s_FOREACH_%(objectMacro)s_BUILTIN_DATA(macro) \\" % args)
+        for function in object.functions:
+            function_args = {
+                'funcName': function.function_name,
+                'mangledName': BuiltinsGenerator.mangledNameForFunction(function),
+                'paramCount': len(function.parameters),
+            }
+
+            lines.append("    macro(%(funcName)s, %(mangledName)s, %(paramCount)d) \\" % function_args)
+        return lines
+
+    def generate_defines_for_object(self, object):
+        lines = []
+        for function in object.functions:
+            args = {
+                'macroPrefix': self.macro_prefix(),
+                'objectMacro': object.object_name.replace('.', '_').upper(),
+                'functionMacro': function.function_name.upper(),
+            }
+            lines.append("#define %(macroPrefix)s_BUILTIN_%(objectMacro)s_%(functionMacro)s 1" % args)
+
+        return lines
+
+    def generate_section_for_code_table_macro(self):
+        args = {
+            'macroPrefix': self.model().framework.setting('macro_prefix'),
+            'objectMacro': self.object.object_name.upper(),
+        }
+
+        lines = []
+        lines.append("#define %(macroPrefix)s_FOREACH_%(objectMacro)s_BUILTIN_CODE(macro) \\" % args)
+        for function in self.object.functions:
+            function_args = {
+                'funcName': function.function_name,
+                'overriddenName': function.overridden_name,
+                'codeName': BuiltinsGenerator.mangledNameForFunction(function) + 'Code',
+            }
+
+            lines.append("    macro(%(codeName)s, %(funcName)s, %(overriddenName)s, s_%(codeName)sLength) \\" % function_args)
+        return '\n'.join(lines)
+
+    def generate_section_for_code_name_macro(self):
+        args = {
+            'macroPrefix': self.macro_prefix(),
+            'objectMacro': self.object.object_name.upper(),
+        }
+
+        lines = []
+        lines.append("#define %(macroPrefix)s_FOREACH_%(objectMacro)s_BUILTIN_FUNCTION_NAME(macro) \\" % args)
+        unique_names = list(set([function.function_name for function in self.object.functions]))
+        unique_names.sort()
+        for function_name in unique_names:
+            function_args = {
+                'funcName': function_name,
+            }
+
+            lines.append("    macro(%(funcName)s) \\" % function_args)
+        return '\n'.join(lines)

Copied: trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generate_separate_implementation.py (from rev 236004, trunk/Source/_javascript_Core/Scripts/builtins/builtins_generate_separate_implementation.py) (0 => 236005)


--- trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generate_separate_implementation.py	                        (rev 0)
+++ trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generate_separate_implementation.py	2018-09-14 15:16:09 UTC (rev 236005)
@@ -0,0 +1,112 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2014, 2015 Apple Inc. All rights reserved.
+# Copyright (c) 2014 University of Washington. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# THE POSSIBILITY OF SUCH DAMAGE.
+
+
+import logging
+import re
+import string
+from string import Template
+
+from builtins_generator import BuiltinsGenerator, WK_lcfirst
+from builtins_model import Framework, Frameworks
+from builtins_templates import BuiltinsGeneratorTemplates as Templates
+
+log = logging.getLogger('global')
+
+
+class BuiltinsSeparateImplementationGenerator(BuiltinsGenerator):
+    def __init__(self, model, object):
+        BuiltinsGenerator.__init__(self, model)
+        self.object = object
+
+    def output_filename(self):
+        return "%sBuiltins.cpp" % BuiltinsGenerator.mangledNameForObject(self.object)
+
+    def macro_prefix(self):
+        return self.model().framework.setting('macro_prefix')
+
+    def generate_output(self):
+        args = {
+            'namespace': self.model().framework.setting('namespace'),
+            'macroPrefix': self.macro_prefix(),
+            'objectMacro': self.object.object_name.upper(),
+            'objectNameLC': WK_lcfirst(self.object.object_name),
+        }
+
+        conditional_guard = self.object.annotations.get('conditional')
+
+        sections = []
+        sections.append(self.generate_license())
+        sections.append(Template(Templates.DoNotEditWarning).substitute(args))
+        sections.append(self.generate_primary_header_includes())
+        if conditional_guard is not None:
+            sections.append("#if %s" % conditional_guard)
+        sections.append(self.generate_secondary_header_includes())
+        sections.append(Template(Templates.NamespaceTop).substitute(args))
+        for function in self.object.functions:
+            sections.append(self.generate_embedded_code_string_section_for_function(function))
+        if self.model().framework is Frameworks._javascript_Core:
+            sections.append(Template(Templates.SeparateJSCImplementationStaticMacros).substitute(args))
+        elif self.model().framework is Frameworks.WebCore:
+            sections.append(Template(Templates.SeparateWebCoreImplementationStaticMacros).substitute(args))
+        sections.append(Template(Templates.NamespaceBottom).substitute(args))
+        if conditional_guard is not None:
+            sections.append("#endif // %s\n" % conditional_guard)
+
+        return "\n\n".join(sections)
+
+    def generate_secondary_header_includes(self):
+        header_includes = [
+            (["_javascript_Core"],
+                ("_javascript_Core", "builtins/BuiltinExecutables.h"),
+            ),
+            (["_javascript_Core", "WebCore"],
+                ("_javascript_Core", "heap/HeapInlines.h"),
+            ),
+            (["_javascript_Core", "WebCore"],
+                ("_javascript_Core", "runtime/JSCellInlines.h"),
+            ),
+            (["WebCore"],
+                ("_javascript_Core", "runtime/StructureInlines.h"),
+            ),
+            (["WebCore"],
+                ("_javascript_Core", "runtime/JSCJSValueInlines.h"),
+            ),
+            (["_javascript_Core", "WebCore"],
+                ("_javascript_Core", "runtime/VM.h"),
+            ),
+            (["WebCore"],
+                ("WebCore", "bindings/js/WebCoreJSClientData.h"),
+            ),
+            (["_javascript_Core", "WebCore"],
+                ("_javascript_Core", "runtime/IdentifierInlines.h"),
+            ),
+            (["_javascript_Core", "WebCore"],
+                ("_javascript_Core", "runtime/Intrinsic.h"),
+            ),
+        ]
+
+        return '\n'.join(self.generate_includes_from_entries(header_includes))

Copied: trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generate_wrapper_header.py (from rev 236004, trunk/Source/_javascript_Core/Scripts/builtins/builtins_generate_wrapper_header.py) (0 => 236005)


--- trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generate_wrapper_header.py	                        (rev 0)
+++ trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generate_wrapper_header.py	2018-09-14 15:16:09 UTC (rev 236005)
@@ -0,0 +1,119 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2016 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# THE POSSIBILITY OF SUCH DAMAGE.
+
+
+import logging
+from string import Template
+
+from builtins_generator import BuiltinsGenerator, WK_lcfirst, WK_ucfirst
+from builtins_templates import BuiltinsGeneratorTemplates as Templates
+
+log = logging.getLogger('global')
+
+
+class BuiltinsWrapperHeaderGenerator(BuiltinsGenerator):
+    def __init__(self, model):
+        BuiltinsGenerator.__init__(self, model)
+
+    def output_filename(self):
+        return "%sJSBuiltins.h" % self.model().framework.setting('namespace')
+
+    def generate_output(self):
+        args = {
+            'namespace': self.model().framework.setting('namespace'),
+        }
+
+        sections = []
+        sections.append(self.generate_license())
+        sections.append(Template(Templates.DoNotEditWarning).substitute(args))
+        sections.append(Template(Templates.HeaderIncludeGuard).substitute(args))
+        sections.append(self.generate_secondary_header_includes())
+
+        sections.append(Template(Templates.NamespaceTop).substitute(args))
+        sections.append(self.generate_section_for_object())
+        sections.append(Template(Templates.NamespaceBottom).substitute(args))
+
+        return "\n\n".join(sections)
+
+    def generate_secondary_header_includes(self):
+        header_includes = [
+            (["WebCore"],
+                ("_javascript_Core", "runtime/VM.h"),
+            ),
+        ]
+        for object in self.model().objects:
+            header_includes.append((["WebCore"], ("WebCore", object.object_name + "Builtins.h")))
+
+        return '\n'.join(self.generate_includes_from_entries(header_includes))
+
+    def generate_section_for_object(self):
+        lines = ["class JSBuiltinFunctions {",
+                 "public:"]
+
+        lines.append(self.generate_constructor())
+        lines.append(self.generate_accessors())
+        lines.append("private:")
+        lines.append(self.generate_members())
+        lines.append("};")
+        return '\n'.join(lines)
+
+    def accessor_name(self, object):
+        return WK_lcfirst(object.object_name) + "Builtins"
+
+    def member_name(self, object):
+        return "m_" + self.accessor_name(object)
+
+    def member_type(self, object):
+        return WK_ucfirst(object.object_name) + "BuiltinsWrapper"
+
+    def generate_constructor(self):
+        lines = ["    explicit JSBuiltinFunctions(JSC::VM& vm)",
+                 "        : m_vm(vm)"]
+        for object in self.model().objects:
+            member_init = "        , %s(&m_vm)" % self.member_name(object)
+            lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), member_init))
+        lines.append("    {")
+        for object in self.model().objects:
+            if not 'internal' in object.annotations:
+                continue
+            internal_export_names = "        %s.exportNames();" % self.member_name(object)
+            lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), internal_export_names))
+        lines.append("    }\n")
+        return '\n'.join(lines)
+
+    def generate_accessors(self):
+        lines = []
+        for object in self.model().objects:
+            accessor = "    %s& %s() { return %s; }" % (self.member_type(object), self.accessor_name(object), self.member_name(object))
+            lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), accessor))
+        lines.append("")
+        return '\n'.join(lines)
+
+    def generate_members(self):
+        lines = ["    JSC::VM& m_vm;"]
+        for object in self.model().objects:
+            member = "    %s %s;" % (self.member_type(object), self.member_name(object))
+            lines.append(BuiltinsGenerator.wrap_with_guard(object.annotations.get('conditional'), member))
+        return '\n'.join(lines)

Copied: trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generate_wrapper_implementation.py (from rev 236004, trunk/Source/_javascript_Core/Scripts/builtins/builtins_generate_wrapper_implementation.py) (0 => 236005)


--- trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generate_wrapper_implementation.py	                        (rev 0)
+++ trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generate_wrapper_implementation.py	2018-09-14 15:16:09 UTC (rev 236005)
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2016 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# THE POSSIBILITY OF SUCH DAMAGE.
+
+
+import logging
+from string import Template
+
+from builtins_generator import BuiltinsGenerator
+from builtins_templates import BuiltinsGeneratorTemplates as Templates
+
+log = logging.getLogger('global')
+
+
+class BuiltinsWrapperImplementationGenerator(BuiltinsGenerator):
+    def __init__(self, model):
+        BuiltinsGenerator.__init__(self, model)
+
+    def output_filename(self):
+        return "%sJSBuiltins.cpp" % self.model().framework.setting('namespace')
+
+    def generate_output(self):
+        args = {
+            'namespace': self.model().framework.setting('namespace'),
+        }
+
+        sections = []
+        sections.append(self.generate_license())
+        sections.append(Template(Templates.DoNotEditWarning).substitute(args))
+
+        sections.append(self.generate_section_for_object())
+
+        return "\n\n".join(sections)
+
+    def generate_section_for_object(self):
+        header_includes = []
+        for object in self.model().objects:
+            header_includes.append((["WebCore"], ("WebCore", object.object_name + "Builtins.cpp")))
+
+        return '\n'.join(self.generate_includes_from_entries(header_includes))

Copied: trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generator.py (from rev 236004, trunk/Source/_javascript_Core/Scripts/builtins/builtins_generator.py) (0 => 236005)


--- trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generator.py	                        (rev 0)
+++ trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_generator.py	2018-09-14 15:16:09 UTC (rev 236005)
@@ -0,0 +1,181 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2014, 2015 Apple Inc. All rights reserved.
+# Copyright (c) 2014 University of Washington. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# THE POSSIBILITY OF SUCH DAMAGE.
+
+import logging
+import os.path
+import re
+from string import Template
+import json
+
+from builtins_model import BuiltinFunction, BuiltinObject
+from builtins_templates import BuiltinsGeneratorTemplates as Templates
+
+log = logging.getLogger('global')
+
+# These match WK_lcfirst and WK_ucfirst defined in CodeGenerator.pm.
+def WK_lcfirst(str):
+    str = str[:1].lower() + str[1:]
+    str = str.replace('dOM', 'dom')
+    str = str.replace('uRL', 'url')
+    str = str.replace('jS', 'js')
+    str = str.replace('xML', 'xml')
+    str = str.replace('xSLT', 'xslt')
+    str = str.replace('cSS', 'css')
+    str = str.replace('rTC', 'rtc')
+    return str
+
+def WK_ucfirst(str):
+    str = str[:1].upper() + str[1:]
+    str = str.replace('Xml', 'XML')
+    str = str.replace('Svg', 'SVG')
+    return str
+
+class BuiltinsGenerator:
+    def __init__(self, model):
+        self._model = model
+
+    def model(self):
+        return self._model
+
+    # These methods are overridden by subclasses.
+
+    def generate_output(self):
+        pass
+
+    def output_filename(self):
+        pass
+
+
+    # Shared code generation methods.
+    def generate_license(self):
+        raw_license = Template(Templates.LicenseText).substitute(None)
+        copyrights = self._model.copyrights()
+        copyrights.sort()
+
+        license_block = []
+        license_block.append("/*")
+        for copyright in copyrights:
+            license_block.append(" * Copyright (c) %s" % copyright)
+        if len(copyrights) > 0:
+            license_block.append(" * ")
+
+        for line in raw_license.split('\n'):
+            license_block.append(" * " + line)
+
+        license_block.append(" */")
+
+        return '\n'.join(license_block)
+
+    def generate_includes_from_entries(self, entries):
+        includes = set()
+        for entry in entries:
+            (allowed_framework_names, data) = entry
+            (framework_name, header_path) = data
+
+            if self.model().framework.name not in allowed_framework_names:
+                continue
+            if self.model().framework.name != framework_name:
+                includes.add("#include <%s/%s>" % (framework_name, os.path.basename(header_path)))
+            else:
+                includes.add("#include \"%s\"" % os.path.basename(header_path))
+
+        return sorted(list(includes))
+
+    def generate_primary_header_includes(self):
+        name, _ = os.path.splitext(self.output_filename())
+        return '\n'.join([
+            "#include \"config.h\"",
+            "#include \"%s.h\"" % name,
+        ])
+
+    def generate_embedded_code_string_section_for_function(self, function):
+        text = function.function_source
+        # Wrap it in parens to avoid adding to global scope.
+        text = "(function " + text[text.index("("):] + ")"
+        embeddedSourceLength = len(text) + 1  # For extra \n.
+        # Lazy way to escape quotes, I think?
+        textLines = json.dumps(text)[1:-1].split("\\n")
+        # This looks scary because we need the JS source itself to have newlines.
+        embeddedSource = '\n'.join(['    "%s\\n" \\' % line for line in textLines])
+
+        constructAbility = "CannotConstruct"
+        if function.is_constructor:
+            constructAbility = "CanConstruct"
+
+        args = {
+            'codeName': BuiltinsGenerator.mangledNameForFunction(function) + 'Code',
+            'embeddedSource': embeddedSource,
+            'embeddedSourceLength': embeddedSourceLength,
+            'canConstruct': constructAbility,
+            'intrinsic': function.intrinsic
+        }
+
+        lines = []
+        lines.append("const JSC::ConstructAbility s_%(codeName)sConstructAbility = JSC::ConstructAbility::%(canConstruct)s;" % args);
+        lines.append("const int s_%(codeName)sLength = %(embeddedSourceLength)d;" % args);
+        lines.append("static const JSC::Intrinsic s_%(codeName)sIntrinsic = JSC::%(intrinsic)s;" % args);
+        lines.append("const char* s_%(codeName)s =\n%(embeddedSource)s\n;" % args);
+        return '\n'.join(lines)
+
+    # Helper methods.
+
+    @staticmethod
+    def wrap_with_guard(guard, text):
+        if not guard:
+            return text
+        return '\n'.join([
+            '#if %s' % guard,
+            text,
+            '#endif // %s' % guard,
+        ])
+
+    @staticmethod
+    def mangledNameForObject(object):
+        if not isinstance(object, BuiltinObject):
+            raise Exception("Invalid argument passed to mangledNameForObject()")
+
+        def toCamel(match):
+            str = match.group(0)
+            return str[1].upper()
+        return re.sub(r'\.[a-z]', toCamel, object.object_name, flags=re.IGNORECASE)
+
+
+    @staticmethod
+    def mangledNameForFunction(function):
+        if not isinstance(function, BuiltinFunction):
+            raise Exception("Invalid argument passed to mangledNameForFunction()")
+
+        function_name = WK_ucfirst(function.function_name)
+
+        def toCamel(match):
+            str = match.group(0)
+            return str[1].upper()
+        function_name = re.sub(r'\.[a-z]', toCamel, function_name, flags=re.IGNORECASE)
+        if function.is_constructor:
+            function_name = function_name + "Constructor"
+
+        object_name = BuiltinsGenerator.mangledNameForObject(function.object)
+        return WK_lcfirst(object_name + function_name)

Copied: trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_model.py (from rev 236004, trunk/Source/_javascript_Core/Scripts/builtins/builtins_model.py) (0 => 236005)


--- trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_model.py	                        (rev 0)
+++ trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_model.py	2018-09-14 15:16:09 UTC (rev 236005)
@@ -0,0 +1,306 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2015-2016 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# THE POSSIBILITY OF SUCH DAMAGE.
+
+import logging
+import re
+import os
+
+from builtins_templates import BuiltinsGeneratorTemplates as Templates
+
+log = logging.getLogger('global')
+
+_FRAMEWORK_CONFIG_MAP = {
+    "_javascript_Core": {
+        "macro_prefix": "JSC",
+        "namespace": "JSC",
+    },
+    "WebCore": {
+        "macro_prefix": "WEBCORE",
+        "namespace": "WebCore",
+    },
+}
+
+functionHeadRegExp = re.compile(r"(?:@[\w|=\[\] \"\.]+\s*\n)*function\s+\w+\s*\(.*?\)", re.MULTILINE | re.DOTALL)
+functionGlobalPrivateRegExp = re.compile(r".*^@globalPrivate", re.MULTILINE | re.DOTALL)
+functionIntrinsicRegExp = re.compile(r".*^@intrinsic=(\w+)", re.MULTILINE | re.DOTALL)
+functionIsConstructorRegExp = re.compile(r".*^@constructor", re.MULTILINE | re.DOTALL)
+functionIsGetterRegExp = re.compile(r".*^@getter", re.MULTILINE | re.DOTALL)
+functionNameRegExp = re.compile(r"function\s+(\w+)\s*\(", re.MULTILINE | re.DOTALL)
+functionOverriddenNameRegExp = re.compile(r".*^@overriddenName=(\".+\")$", re.MULTILINE | re.DOTALL)
+functionParameterFinder = re.compile(r"^function\s+(?:\w+)\s*\(((?:\s*\w+)?\s*(?:\s*,\s*\w+)*)?\s*\)", re.MULTILINE | re.DOTALL)
+
+multilineCommentRegExp = re.compile(r"\/\*.*?\*\/", re.MULTILINE | re.DOTALL)
+singleLineCommentRegExp = re.compile(r"\/\/.*?\n", re.MULTILINE | re.DOTALL)
+keyValueAnnotationCommentRegExp = re.compile(r"^\/\/ @(\w+)=([^=]+?)\n", re.MULTILINE | re.DOTALL)
+flagAnnotationCommentRegExp = re.compile(r"^\/\/ @(\w+)[^=]*?\n", re.MULTILINE | re.DOTALL)
+lineWithOnlySingleLineCommentRegExp = re.compile(r"^\s*\/\/\n", re.MULTILINE | re.DOTALL)
+lineWithTrailingSingleLineCommentRegExp = re.compile(r"\s*\/\/\n", re.MULTILINE | re.DOTALL)
+leadingWhitespaceRegExp = re.compile(r"^ +", re.MULTILINE | re.DOTALL)
+multipleEmptyLinesRegExp = re.compile(r"\n{2,}", re.MULTILINE | re.DOTALL)
+
+class ParseException(Exception):
+    pass
+
+
+class Framework:
+    def __init__(self, name):
+        self._settings = _FRAMEWORK_CONFIG_MAP[name]
+        self.name = name
+
+    def setting(self, key, default=''):
+        return self._settings.get(key, default)
+
+    @staticmethod
+    def fromString(frameworkString):
+        if frameworkString == "_javascript_Core":
+            return Frameworks._javascript_Core
+
+        if frameworkString == "WebCore":
+            return Frameworks.WebCore
+
+        raise ParseException("Unknown framework: %s" % frameworkString)
+
+
+class Frameworks:
+    _javascript_Core = Framework("_javascript_Core")
+    WebCore = Framework("WebCore")
+
+
+class BuiltinObject:
+    def __init__(self, object_name, annotations, functions):
+        self.object_name = object_name
+        self.annotations = annotations
+        self.functions = functions
+        self.collection = None  # Set by the owning BuiltinsCollection
+
+        for function in self.functions:
+            function.object = self
+
+
+class BuiltinFunction:
+    def __init__(self, function_name, function_source, parameters, is_constructor, is_global_private, intrinsic, overridden_name):
+        self.function_name = function_name
+        self.function_source = function_source
+        self.parameters = parameters
+        self.is_constructor = is_constructor
+        self.is_global_private = is_global_private
+        self.intrinsic = intrinsic
+        self.overridden_name = overridden_name
+        self.object = None  # Set by the owning BuiltinObject
+
+    @staticmethod
+    def fromString(function_string):
+        function_source = multilineCommentRegExp.sub("", function_string)
+
+        intrinsic = "NoIntrinsic"
+        intrinsicMatch = functionIntrinsicRegExp.search(function_source)
+        if intrinsicMatch:
+            intrinsic = intrinsicMatch.group(1)
+            function_source = functionIntrinsicRegExp.sub("", function_source)
+
+        overridden_name = None
+        overriddenNameMatch = functionOverriddenNameRegExp.search(function_source)
+        if overriddenNameMatch:
+            overridden_name = overriddenNameMatch.group(1)
+            function_source = functionOverriddenNameRegExp.sub("", function_source)
+
+        if not os.getenv("CONFIGURATION", "Debug").startswith("Debug"):
+            function_source = lineWithOnlySingleLineCommentRegExp.sub("", function_source)
+            function_source = lineWithTrailingSingleLineCommentRegExp.sub("\n", function_source)
+            function_source = leadingWhitespaceRegExp.sub("", function_source)
+            function_source = multipleEmptyLinesRegExp.sub("\n", function_source)
+
+        function_name = functionNameRegExp.findall(function_source)[0]
+        is_constructor = functionIsConstructorRegExp.match(function_source) != None
+        is_getter = functionIsGetterRegExp.match(function_source) != None
+        is_global_private = functionGlobalPrivateRegExp.match(function_source) != None
+        parameters = [s.strip() for s in functionParameterFinder.findall(function_source)[0].split(',')]
+        if len(parameters[0]) == 0:
+            parameters = []
+
+        if is_getter and not overridden_name:
+            overridden_name = "\"get %s\"" % (function_name)
+
+        if not overridden_name:
+            overridden_name = "static_cast<const char*>(nullptr)"
+
+        return BuiltinFunction(function_name, function_source, parameters, is_constructor, is_global_private, intrinsic, overridden_name)
+
+    def __str__(self):
+        interface = "%s(%s)" % (self.function_name, ', '.join(self.parameters))
+        if self.is_constructor:
+            interface = interface + " [Constructor]"
+
+        return interface
+
+
+class BuiltinsCollection:
+    def __init__(self, framework_name):
+        self._copyright_lines = set()
+        self.objects = []
+        self.framework = Framework.fromString(framework_name)
+        log.debug("Created new Builtins collection.")
+
+    def parse_builtins_file(self, filename, text):
+        log.debug("Parsing builtins file: %s" % filename)
+
+        parsed_copyrights = set(self._parse_copyright_lines(text))
+        self._copyright_lines = self._copyright_lines.union(parsed_copyrights)
+
+        log.debug("Found copyright lines:")
+        for line in self._copyright_lines:
+            log.debug(line)
+        log.debug("")
+
+        object_annotations = self._parse_annotations(text)
+
+        object_name, ext = os.path.splitext(os.path.basename(filename))
+        log.debug("Parsing object: %s" % object_name)
+
+        parsed_functions = self._parse_functions(text)
+        for function in parsed_functions:
+            function.object = object_name
+
+        log.debug("Parsed functions:")
+        for func in parsed_functions:
+            log.debug(func)
+        log.debug("")
+
+        new_object = BuiltinObject(object_name, object_annotations, parsed_functions)
+        new_object.collection = self
+        self.objects.append(new_object)
+
+    def copyrights(self):
+        owner_to_years = dict()
+        copyrightYearRegExp = re.compile(r"(\d{4})[, ]{0,2}")
+        ownerStartRegExp = re.compile(r"[^\d, ]")
+
+        # Returns deduplicated copyrights keyed on the owner.
+        for line in self._copyright_lines:
+            years = set(copyrightYearRegExp.findall(line))
+            ownerIndex = ownerStartRegExp.search(line).start()
+            owner = line[ownerIndex:]
+            log.debug("Found years: %s and owner: %s" % (years, owner))
+            if owner not in owner_to_years:
+                owner_to_years[owner] = set()
+
+            owner_to_years[owner] = owner_to_years[owner].union(years)
+
+        result = []
+
+        for owner, years in owner_to_years.items():
+            sorted_years = list(years)
+            sorted_years.sort()
+            result.append("%s %s" % (', '.join(sorted_years), owner))
+
+        return result
+
+    def all_functions(self):
+        result = []
+        for object in self.objects:
+            result.extend(object.functions)
+
+        result.sort()
+        return result
+
+    def all_internal_functions(self):
+        result = []
+        for object in [o for o in self.objects if 'internal' in o.annotations]:
+            result.extend(object.functions)
+
+        result.sort()
+        return result
+
+    # Private methods.
+
+    def _parse_copyright_lines(self, text):
+        licenseBlock = multilineCommentRegExp.findall(text)[0]
+        licenseBlock = licenseBlock[:licenseBlock.index("Redistribution")]
+
+        copyrightLines = [Templates.DefaultCopyright]
+        for line in licenseBlock.split("\n"):
+            line = line.replace("/*", "")
+            line = line.replace("*/", "")
+            line = line.replace("*", "")
+            line = line.replace("Copyright", "")
+            line = line.replace("copyright", "")
+            line = line.replace("(C)", "")
+            line = line.replace("(c)", "")
+            line = line.strip()
+
+            if len(line) == 0:
+                continue
+
+            copyrightLines.append(line)
+
+        return copyrightLines
+
+    def _parse_annotations(self, text):
+        annotations = {}
+
+        for match in keyValueAnnotationCommentRegExp.finditer(text):
+            (key, value) = match.group(1, 2)
+            log.debug("Found annotation: '%s' => '%s'" % (key, value))
+            if key in annotations:
+                raise ParseException("Duplicate annotation found: %s" % key)
+
+            annotations[key] = value
+
+        for match in flagAnnotationCommentRegExp.finditer(text):
+            key = match.group(1)
+            log.debug("Found annotation: '%s' => 'TRUE'" % key)
+            if key in annotations:
+                raise ParseException("Duplicate annotation found: %s" % key)
+
+            annotations[key] = True
+
+        return annotations
+
+    def _parse_functions(self, text):
+        text = multilineCommentRegExp.sub("/**/", singleLineCommentRegExp.sub("//\n", text))
+
+        matches = [func for func in functionHeadRegExp.finditer(text)]
+        functionBounds = []
+        start = 0
+        end = 0
+        for match in matches:
+            start = match.start()
+            if start < end:
+                continue
+            end = match.end()
+            while text[end] != '{':
+                end = end + 1
+            depth = 1
+            end = end + 1
+            while depth > 0:
+                if text[end] == '{':
+                    depth = depth + 1
+                elif text[end] == '}':
+                    depth = depth - 1
+                end = end + 1
+            functionBounds.append((start, end))
+
+        functionStrings = [text[start:end].strip() for (start, end) in functionBounds]
+        return map(BuiltinFunction.fromString, functionStrings)

Copied: trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_templates.py (from rev 236004, trunk/Source/_javascript_Core/Scripts/builtins/builtins_templates.py) (0 => 236005)


--- trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_templates.py	                        (rev 0)
+++ trunk/Source/_javascript_Core/Scripts/wkbuiltins/builtins_templates.py	2018-09-14 15:16:09 UTC (rev 236005)
@@ -0,0 +1,216 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2014-2016 Apple Inc. All rights reserved.
+# Copyright (C) 2015 Canon Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# THE POSSIBILITY OF SUCH DAMAGE.
+
+# Builtins generator templates, which can be filled with string.Template.
+
+
+class BuiltinsGeneratorTemplates:
+
+    DefaultCopyright = "2016 Apple Inc. All rights reserved."
+    LicenseText = (
+    """Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+""")
+
+    DoNotEditWarning = (
+    """// DO NOT EDIT THIS FILE. It is automatically generated from _javascript_ files for
+// builtins by the script: Source/_javascript_Core/Scripts/generate-js-builtins.py""")
+
+    HeaderIncludeGuard = (
+    """#pragma once""")
+
+    NamespaceTop = (
+    """namespace ${namespace} {""")
+
+    NamespaceBottom = (
+    """} // namespace ${namespace}""")
+
+    CombinedHeaderStaticMacros = (
+    """#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\
+    JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
+
+${macroPrefix}_FOREACH_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
+#undef DECLARE_BUILTIN_GENERATOR""")
+
+    SeparateHeaderStaticMacros = (
+    """#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\
+    JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
+
+${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
+#undef DECLARE_BUILTIN_GENERATOR""")
+
+    CombinedJSCImplementationStaticMacros = (
+    """
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\
+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \\
+{\\
+    return vm.builtinExecutables()->codeName##Executable()->link(vm, vm.builtinExecutables()->codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
+}
+${macroPrefix}_FOREACH_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
+#undef DEFINE_BUILTIN_GENERATOR
+""")
+
+    SeparateJSCImplementationStaticMacros = (
+    """
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\
+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \\
+{\\
+    return vm.builtinExecutables()->codeName##Executable()->link(vm, vm.builtinExecutables()->codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
+}
+${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
+#undef DEFINE_BUILTIN_GENERATOR
+""")
+
+    CombinedWebCoreImplementationStaticMacros = (
+        """
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\
+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \\
+{\\
+    JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \\
+    return clientData->builtinFunctions().${objectNameLC}Builtins().codeName##Executable()->link(vm, clientData->builtinFunctions().${objectNameLC}Builtins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \\
+}
+${macroPrefix}_FOREACH_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
+#undef DEFINE_BUILTIN_GENERATOR
+""")
+
+    SeparateWebCoreImplementationStaticMacros = (
+        """
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\
+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \\
+{\\
+    JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \\
+    return clientData->builtinFunctions().${objectNameLC}Builtins().codeName##Executable()->link(vm, clientData->builtinFunctions().${objectNameLC}Builtins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \\
+}
+${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
+#undef DEFINE_BUILTIN_GENERATOR
+""")
+
+    SeparateHeaderWrapperBoilerplate = (
+    """class ${objectName}BuiltinsWrapper : private JSC::WeakHandleOwner {
+public:
+    explicit ${objectName}BuiltinsWrapper(JSC::VM* vm)
+        : m_vm(*vm)
+        ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
+#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
+        ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
+#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
+    {
+    }
+
+#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \\
+    JSC::UnlinkedFunctionExecutable* name##Executable(); \\
+    const JSC::SourceCode& name##Source() const { return m_##name##Source; }
+    ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
+#undef EXPOSE_BUILTIN_EXECUTABLES
+
+    ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
+
+    void exportNames();
+
+private:
+    JSC::VM& m_vm;
+
+    ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
+
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \\
+    JSC::SourceCode m_##name##Source;\\
+    JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
+    ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
+#undef DECLARE_BUILTIN_SOURCE_MEMBERS
+
+};
+
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \\
+inline JSC::UnlinkedFunctionExecutable* ${objectName}BuiltinsWrapper::name##Executable() \\
+{\\
+    if (!m_##name##Executable) {\\
+        JSC::Identifier executableName = functionName##PublicName();\\
+        if (overriddenName)\\
+            executableName = JSC::Identifier::fromString(&m_vm, overriddenName);\\
+        m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructAbility), this, &m_##name##Executable);\\
+    }\\
+    return m_##name##Executable.get();\\
+}
+${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
+#undef DEFINE_BUILTIN_EXECUTABLES
+
+inline void ${objectName}BuiltinsWrapper::exportNames()
+{
+#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
+    ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
+#undef EXPORT_FUNCTION_NAME
+}""")
+
+    SeparateHeaderInternalFunctionsBoilerplate = (
+    """class ${objectName}BuiltinFunctions {
+public:
+    explicit ${objectName}BuiltinFunctions(JSC::VM& vm) : m_vm(vm) { }
+
+    void init(JSC::JSGlobalObject&);
+    void visit(JSC::SlotVisitor&);
+
+public:
+    JSC::VM& m_vm;
+
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(functionName) \\
+    JSC::WriteBarrier<JSC::JSFunction> m_##functionName##Function;
+    ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_SOURCE_MEMBERS)
+#undef DECLARE_BUILTIN_SOURCE_MEMBERS
+};
+
+inline void ${objectName}BuiltinFunctions::init(JSC::JSGlobalObject& globalObject)
+{
+#define EXPORT_FUNCTION(codeName, functionName, overriddenName, length)\\
+    m_##functionName##Function.set(m_vm, &globalObject, JSC::JSFunction::create(m_vm, codeName##Generator(m_vm), &globalObject));
+    ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(EXPORT_FUNCTION)
+#undef EXPORT_FUNCTION
+}
+
+inline void ${objectName}BuiltinFunctions::visit(JSC::SlotVisitor& visitor)
+{
+#define VISIT_FUNCTION(name) visitor.append(m_##name##Function);
+    ${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_FUNCTION_NAME(VISIT_FUNCTION)
+#undef VISIT_FUNCTION
+}
+""")

Copied: trunk/Source/_javascript_Core/Scripts/wkbuiltins/wkbuiltins.py (from rev 236004, trunk/Source/_javascript_Core/Scripts/builtins/builtins.py) (0 => 236005)


--- trunk/Source/_javascript_Core/Scripts/wkbuiltins/wkbuiltins.py	                        (rev 0)
+++ trunk/Source/_javascript_Core/Scripts/wkbuiltins/wkbuiltins.py	2018-09-14 15:16:09 UTC (rev 236005)
@@ -0,0 +1,15 @@
+# This file is used to simulate the wkbuiltins/ directory when generate-js-builtins.py
+# is run from _javascript_Core framework's private headers directory, which is flattened.
+
+from builtins_model import *
+from builtins_templates import *
+
+from builtins_generator import *
+from builtins_generate_combined_header import *
+from builtins_generate_combined_implementation import *
+from builtins_generate_separate_header import *
+from builtins_generate_separate_implementation import *
+from builtins_generate_wrapper_header import *
+from builtins_generate_wrapper_implementation import *
+from builtins_generate_internals_wrapper_header import *
+from builtins_generate_internals_wrapper_implementation import *

Modified: trunk/Source/WebCore/CMakeLists.txt (236004 => 236005)


--- trunk/Source/WebCore/CMakeLists.txt	2018-09-14 11:01:06 UTC (rev 236004)
+++ trunk/Source/WebCore/CMakeLists.txt	2018-09-14 15:16:09 UTC (rev 236005)
@@ -1870,7 +1870,7 @@
 )
 
 set(BUILTINS_GENERATOR_SCRIPTS
-    ${_javascript_Core_SCRIPTS_DIR}/builtins.py
+    ${_javascript_Core_SCRIPTS_DIR}/wkbuiltins.py
     ${_javascript_Core_SCRIPTS_DIR}/builtins_generator.py
     ${_javascript_Core_SCRIPTS_DIR}/builtins_model.py
     ${_javascript_Core_SCRIPTS_DIR}/builtins_templates.py

Modified: trunk/Source/WebCore/ChangeLog (236004 => 236005)


--- trunk/Source/WebCore/ChangeLog	2018-09-14 11:01:06 UTC (rev 236004)
+++ trunk/Source/WebCore/ChangeLog	2018-09-14 15:16:09 UTC (rev 236005)
@@ -1,3 +1,15 @@
+2018-09-14  Mike Gorse  <[email protected]>
+
+        builtins directory causes name conflict on Python 3
+        https://bugs.webkit.org/show_bug.cgi?id=189552
+
+        Reviewed by Michael Catanzaro.
+
+        No new tests (No behavior change).
+
+        * CMakeLists.txt: builtins -> wkbuiltins.
+        * DerivedSources.make: builtins -> wkbuiltins.
+
 2018-09-13  Ryosuke Niwa  <[email protected]>
 
         Capturing event listeners are called during bubbling phase for shadow hosts

Modified: trunk/Source/WebCore/DerivedSources.make (236004 => 236005)


--- trunk/Source/WebCore/DerivedSources.make	2018-09-14 11:01:06 UTC (rev 236004)
+++ trunk/Source/WebCore/DerivedSources.make	2018-09-14 15:16:09 UTC (rev 236005)
@@ -1550,7 +1550,7 @@
 #
 
 BUILTINS_GENERATOR_SCRIPTS = \
-    $(_javascript_Core_SCRIPTS_DIR)/builtins.py \
+    $(_javascript_Core_SCRIPTS_DIR)/wkbuiltins.py \
     $(_javascript_Core_SCRIPTS_DIR)/builtins_generator.py \
     $(_javascript_Core_SCRIPTS_DIR)/builtins_model.py \
     $(_javascript_Core_SCRIPTS_DIR)/builtins_templates.py \
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to