Automatically generate WorkerContext constructor attributes
authorch.dumez@sisa.samsung.com <ch.dumez@sisa.samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Jun 2013 14:17:51 +0000 (14:17 +0000)
committerch.dumez@sisa.samsung.com <ch.dumez@sisa.samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Jun 2013 14:17:51 +0000 (14:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=117183

Reviewed by Kentaro Hara.

.:

Update GENERATE_BINDINGS macro to take an additional _workercontext_constructors_file
optional argument.

* Source/cmake/WebKitMacros.cmake:

Source/WebCore:

Add [GlobalContext=WindowOnly|WorkerOnly|WindowAndWorker] IDL extended attribute
to indicate to the bindings generator on which global context the constructor
attribute should be generated for interfaces without [NoInterfaceObject]:
- WindowOnly: only on the global Window object (default if ommitted)
- WorkerOnly: only on the worker context
- WindowAndWorker: On both the global Window object and the worker context

This covers all the current use cases.

The JSC bindings generator now automatically generates the Constructor attributes
on the WorkerContext for non-callback interfaces which do not have the
[NoInterfaceObject] extended attribute but have [GlobalContext=WorkerOnly|WindowAndWorker]
extended attribute.

No new tests, already covered by:
fast/js/global-constructors-attributes.html
fast/js/global-constructors-attributes-worker.html

* CMakeLists.txt:
* DerivedSources.make: Pass new --workerContextConstructorsFile argument to preprocess-idls.pl.
* DerivedSources.pri: Ditto.
* GNUmakefile.am: Ditto.
* PlatformBlackBerry.cmake: Ditto.
* UseJSC.cmake: Ditto.
* bindings/scripts/IDLAttributes.txt: Add [GlobalContext=WindowOnly|WorkerOnly|WindowAndWorker]
IDL extended attribute.
* bindings/scripts/preprocess-idls.pl: Add support for [GlobalContext] extended attribute and
generate a partial interface for WorkerContext global constructors that are automatically
generated.
* dom/MessageEvent.idl: Add [GlobalContext=WindowAndWorker].
* fileapi/Blob.idl: Add [GlobalContext=WindowAndWorker].
* fileapi/FileReader.idl: Add [GlobalContext=WindowAndWorker].
* fileapi/FileReaderSync.idl: Add [GlobalContext=WorkerOnly] and remove [NoInterfaceObject]
as the interface should only be visible in worker environment as per the spec.
* html/DOMURL.idl: Add [GlobalContext=WindowAndWorker].
* html/canvas/ArrayBuffer.idl: Add [GlobalContext=WindowAndWorker].
* html/canvas/DataView.idl: Add [GlobalContext=WindowAndWorker].
* html/canvas/Float32Array.idl: Add [GlobalContext=WindowAndWorker].
* html/canvas/Float64Array.idl: Add [GlobalContext=WindowAndWorker].
* html/canvas/Int16Array.idl: Add [GlobalContext=WindowAndWorker].
* html/canvas/Int32Array.idl: Add [GlobalContext=WindowAndWorker].
* html/canvas/Int8Array.idl: Add [GlobalContext=WindowAndWorker].
* html/canvas/Uint16Array.idl: Add [GlobalContext=WindowAndWorker].
* html/canvas/Uint32Array.idl: Add [GlobalContext=WindowAndWorker].
* html/canvas/Uint8Array.idl: Add [GlobalContext=WindowAndWorker].
* html/canvas/Uint8ClampedArray.idl: Add [GlobalContext=WindowAndWorker].
* workers/WorkerContext.idl: Remove several Constructor attributes which are now automatically
generated.
* workers/WorkerLocation.idl: Add [GlobalContext=WorkerOnly] and remove [NoInterfaceObject]
as the interface should only be visible in worker environment as per the spec.

Tools:

Pass new --workerContextConstructorsFile to preprocess-idl.pl for bindings
tests.

* Scripts/webkitpy/bindings/main.py:
(BindingsTests.generate_supplemental_dependency):
(BindingsTests.main):

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

31 files changed:
ChangeLog
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/DerivedSources.pri
Source/WebCore/GNUmakefile.am
Source/WebCore/PlatformBlackBerry.cmake
Source/WebCore/UseJSC.cmake
Source/WebCore/bindings/scripts/IDLAttributes.txt
Source/WebCore/bindings/scripts/preprocess-idls.pl
Source/WebCore/dom/MessageEvent.idl
Source/WebCore/fileapi/Blob.idl
Source/WebCore/fileapi/FileReader.idl
Source/WebCore/fileapi/FileReaderSync.idl
Source/WebCore/html/DOMURL.idl
Source/WebCore/html/canvas/ArrayBuffer.idl
Source/WebCore/html/canvas/DataView.idl
Source/WebCore/html/canvas/Float32Array.idl
Source/WebCore/html/canvas/Float64Array.idl
Source/WebCore/html/canvas/Int16Array.idl
Source/WebCore/html/canvas/Int32Array.idl
Source/WebCore/html/canvas/Int8Array.idl
Source/WebCore/html/canvas/Uint16Array.idl
Source/WebCore/html/canvas/Uint32Array.idl
Source/WebCore/html/canvas/Uint8Array.idl
Source/WebCore/html/canvas/Uint8ClampedArray.idl
Source/WebCore/workers/WorkerContext.idl
Source/WebCore/workers/WorkerLocation.idl
Source/cmake/WebKitMacros.cmake
Tools/ChangeLog
Tools/Scripts/webkitpy/bindings/main.py

index b2e8b6b..a3cd70c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2013-06-04  Christophe Dumez  <ch.dumez@sisa.samsung.com>
+
+        Automatically generate WorkerContext constructor attributes
+        https://bugs.webkit.org/show_bug.cgi?id=117183
+
+        Reviewed by Kentaro Hara.
+
+        Update GENERATE_BINDINGS macro to take an additional _workercontext_constructors_file
+        optional argument.
+
+        * Source/cmake/WebKitMacros.cmake:
+
 2013-06-03  Eduardo Lima Mitev  <elima@igalia.com>
 
         [EFL] Add ATK version 2.8.0 to efl jhbuild moduleset
index 8c5a89f..7bd8085 100644 (file)
@@ -2946,6 +2946,7 @@ set(SCRIPTS_BINDINGS
 set(IDL_FILES_TMP ${DERIVED_SOURCES_WEBCORE_DIR}/idl_files.tmp)
 set(SUPPLEMENTAL_DEPENDENCY_FILE ${DERIVED_SOURCES_WEBCORE_DIR}/supplemental_dependency.tmp)
 set(WINDOW_CONSTRUCTORS_FILE ${DERIVED_SOURCES_WEBCORE_DIR}/DOMWindowConstructors.idl)
+set(WORKERCONTEXT_CONSTRUCTORS_FILE ${DERIVED_SOURCES_WEBCORE_DIR}/WorkerContextConstructors.idl)
 set(IDL_ATTRIBUTES_FILE ${WEBCORE_DIR}/bindings/scripts/IDLAttributes.txt)
 
 include(${WEBCORE_DIR}/UseJSC.cmake)
index 9ad68e5..122f1e2 100644 (file)
@@ -1,3 +1,61 @@
+2013-06-04  Christophe Dumez  <ch.dumez@sisa.samsung.com>
+
+        Automatically generate WorkerContext constructor attributes
+        https://bugs.webkit.org/show_bug.cgi?id=117183
+
+        Reviewed by Kentaro Hara.
+
+        Add [GlobalContext=WindowOnly|WorkerOnly|WindowAndWorker] IDL extended attribute
+        to indicate to the bindings generator on which global context the constructor
+        attribute should be generated for interfaces without [NoInterfaceObject]:
+        - WindowOnly: only on the global Window object (default if ommitted)
+        - WorkerOnly: only on the worker context
+        - WindowAndWorker: On both the global Window object and the worker context
+
+        This covers all the current use cases.
+
+        The JSC bindings generator now automatically generates the Constructor attributes
+        on the WorkerContext for non-callback interfaces which do not have the
+        [NoInterfaceObject] extended attribute but have [GlobalContext=WorkerOnly|WindowAndWorker]
+        extended attribute.
+
+        No new tests, already covered by:
+        fast/js/global-constructors-attributes.html
+        fast/js/global-constructors-attributes-worker.html
+
+        * CMakeLists.txt:
+        * DerivedSources.make: Pass new --workerContextConstructorsFile argument to preprocess-idls.pl.
+        * DerivedSources.pri: Ditto.
+        * GNUmakefile.am: Ditto.
+        * PlatformBlackBerry.cmake: Ditto.
+        * UseJSC.cmake: Ditto.
+        * bindings/scripts/IDLAttributes.txt: Add [GlobalContext=WindowOnly|WorkerOnly|WindowAndWorker]
+        IDL extended attribute.
+        * bindings/scripts/preprocess-idls.pl: Add support for [GlobalContext] extended attribute and
+        generate a partial interface for WorkerContext global constructors that are automatically
+        generated.
+        * dom/MessageEvent.idl: Add [GlobalContext=WindowAndWorker].
+        * fileapi/Blob.idl: Add [GlobalContext=WindowAndWorker].
+        * fileapi/FileReader.idl: Add [GlobalContext=WindowAndWorker].
+        * fileapi/FileReaderSync.idl: Add [GlobalContext=WorkerOnly] and remove [NoInterfaceObject]
+        as the interface should only be visible in worker environment as per the spec.
+        * html/DOMURL.idl: Add [GlobalContext=WindowAndWorker].
+        * html/canvas/ArrayBuffer.idl: Add [GlobalContext=WindowAndWorker].
+        * html/canvas/DataView.idl: Add [GlobalContext=WindowAndWorker].
+        * html/canvas/Float32Array.idl: Add [GlobalContext=WindowAndWorker].
+        * html/canvas/Float64Array.idl: Add [GlobalContext=WindowAndWorker].
+        * html/canvas/Int16Array.idl: Add [GlobalContext=WindowAndWorker].
+        * html/canvas/Int32Array.idl: Add [GlobalContext=WindowAndWorker].
+        * html/canvas/Int8Array.idl: Add [GlobalContext=WindowAndWorker].
+        * html/canvas/Uint16Array.idl: Add [GlobalContext=WindowAndWorker].
+        * html/canvas/Uint32Array.idl: Add [GlobalContext=WindowAndWorker].
+        * html/canvas/Uint8Array.idl: Add [GlobalContext=WindowAndWorker].
+        * html/canvas/Uint8ClampedArray.idl: Add [GlobalContext=WindowAndWorker].
+        * workers/WorkerContext.idl: Remove several Constructor attributes which are now automatically
+        generated.
+        * workers/WorkerLocation.idl: Add [GlobalContext=WorkerOnly] and remove [NoInterfaceObject]
+        as the interface should only be visible in worker environment as per the spec.
+
 2013-06-04  Kangil Han  <kangil.han@samsung.com>
 
         Use ASSERT_DISABLED option for assertion purpose code in InlineBox
index 6fe1002..2d7ae96 100644 (file)
@@ -660,6 +660,7 @@ WEB_DOM_HEADERS :=
 all : \
     $(SUPPLEMENTAL_DEPENDENCY_FILE) \
     $(WINDOW_CONSTRUCTORS_FILE) \
+    $(WORKERCONTEXT_CONSTRUCTORS_FILE) \
     $(JS_DOM_HEADERS) \
     $(WEB_DOM_HEADERS) \
     \
@@ -1005,6 +1006,7 @@ JS_BINDINGS_SCRIPTS = $(GENERATE_SCRIPTS) bindings/scripts/CodeGeneratorJS.pm
 SUPPLEMENTAL_DEPENDENCY_FILE = ./SupplementalDependencies.txt
 SUPPLEMENTAL_MAKEFILE_DEPS = ./SupplementalDependencies.dep
 WINDOW_CONSTRUCTORS_FILE = ./DOMWindowConstructors.idl
+WORKERCONTEXT_CONSTRUCTORS_FILE = ./WorkerContextConstructors.idl
 IDL_FILES_TMP = ./idl_files.tmp
 ADDITIONAL_IDLS = $(WebCore)/inspector/JavaScriptCallFrame.idl
 IDL_ATTRIBUTES_FILE = $(WebCore)/bindings/scripts/IDLAttributes.txt
@@ -1016,10 +1018,10 @@ space +=
 
 $(SUPPLEMENTAL_MAKEFILE_DEPS) : $(PREPROCESS_IDLS_SCRIPTS) $(BINDING_IDLS) $(ADDITIONAL_IDLS) $(PLATFORM_FEATURE_DEFINES)
        printf "$(subst $(space),,$(patsubst %,%\n,$(BINDING_IDLS) $(ADDITIONAL_IDLS)))" > $(IDL_FILES_TMP)
-       $(call preprocess_idls_script, $(PREPROCESS_IDLS_SCRIPTS)) --defines "$(FEATURE_DEFINES) $(ADDITIONAL_IDL_DEFINES) LANGUAGE_JAVASCRIPT" --idlFilesList $(IDL_FILES_TMP) --supplementalDependencyFile $(SUPPLEMENTAL_DEPENDENCY_FILE) --windowConstructorsFile $(WINDOW_CONSTRUCTORS_FILE) --supplementalMakefileDeps $@
+       $(call preprocess_idls_script, $(PREPROCESS_IDLS_SCRIPTS)) --defines "$(FEATURE_DEFINES) $(ADDITIONAL_IDL_DEFINES) LANGUAGE_JAVASCRIPT" --idlFilesList $(IDL_FILES_TMP) --supplementalDependencyFile $(SUPPLEMENTAL_DEPENDENCY_FILE) --windowConstructorsFile $(WINDOW_CONSTRUCTORS_FILE) --workerContextConstructorsFile $(WORKERCONTEXT_CONSTRUCTORS_FILE) --supplementalMakefileDeps $@
        rm -f $(IDL_FILES_TMP)
 
-JS%.h : %.idl $(JS_BINDINGS_SCRIPTS) $(IDL_ATTRIBUTES_FILE) $(WINDOW_CONSTRUCTORS_FILE) $(PLATFORM_FEATURE_DEFINES)
+JS%.h : %.idl $(JS_BINDINGS_SCRIPTS) $(IDL_ATTRIBUTES_FILE) $(WINDOW_CONSTRUCTORS_FILE) $(WORKERCONTEXT_CONSTRUCTORS_FILE) $(PLATFORM_FEATURE_DEFINES)
        $(call generator_script, $(JS_BINDINGS_SCRIPTS)) $(IDL_COMMON_ARGS) --defines "$(FEATURE_DEFINES) $(ADDITIONAL_IDL_DEFINES) LANGUAGE_JAVASCRIPT" --generator JS --idlAttributesFile $(IDL_ATTRIBUTES_FILE) --supplementalDependencyFile $(SUPPLEMENTAL_DEPENDENCY_FILE) $<
 
 include $(SUPPLEMENTAL_MAKEFILE_DEPS)
index 895c011..0fd2045 100644 (file)
@@ -731,6 +731,7 @@ IDL_BINDINGS += generated/$$INTERNAL_SETTINGS_GENERATED_IDL
 # GENERATOR 0: Resolve [Supplemental] dependency in IDLs
 SUPPLEMENTAL_DEPENDENCY_FILE = supplemental_dependency.tmp
 WINDOW_CONSTRUCTORS_FILE = DOMWindowConstructors.idl
+WORKERCONTEXT_CONSTRUCTORS_FILE = WorkerContextConstructors.idl
 IDL_FILES_TMP = ${QMAKE_FUNC_FILE_OUT_PATH}/idl_files.tmp
 PREPROCESS_IDLS_SCRIPT = $$PWD/bindings/scripts/preprocess-idls.pl
 IDL_ATTRIBUTES_FILE = $$PWD/bindings/scripts/IDLAttributes.txt
@@ -749,8 +750,9 @@ preprocessIdls.commands += perl -I$$PWD/bindings/scripts $$preprocessIdls.script
                                --defines \"$$javascriptFeatureDefines()\" \
                                --idlFilesList $$IDL_FILES_TMP \
                                --supplementalDependencyFile ${QMAKE_FUNC_FILE_OUT_PATH}/$$SUPPLEMENTAL_DEPENDENCY_FILE \
-                               --windowConstructorsFile ${QMAKE_FUNC_FILE_OUT_PATH}/$$WINDOW_CONSTRUCTORS_FILE
-preprocessIdls.output = $$SUPPLEMENTAL_DEPENDENCY_FILE $$WINDOW_CONSTRUCTORS_FILE
+                               --windowConstructorsFile ${QMAKE_FUNC_FILE_OUT_PATH}/$$WINDOW_CONSTRUCTORS_FILE \
+                               --workerContextConstructorsFile ${QMAKE_FUNC_FILE_OUT_PATH}/$$WORKERCONTEXT_CONSTRUCTORS_FILE
+preprocessIdls.output = $$SUPPLEMENTAL_DEPENDENCY_FILE $$WINDOW_CONSTRUCTORS_FILE $$WORKERCONTEXT_CONSTRUCTORS_FILE
 preprocessIdls.add_output_to_sources = false
 preprocessIdls.depends = $$IDL_BINDINGS
 GENERATORS += preprocessIdls
index cb7da9b..0a52883 100644 (file)
@@ -402,6 +402,7 @@ vpath %.idl $(IDL_PATH)
 
 supplemental_dependency_file = $(top_builddir)/DerivedSources/WebCore/idl_supplemental_dependencies
 window_constructors_file = $(top_builddir)/DerivedSources/WebCore/DOMWindowConstructors.idl
+workercontext_constructors_file = $(top_builddir)/DerivedSources/WebCore/WorkerContextConstructors.idl
 idl_files_list = $(top_builddir)/DerivedSources/WebCore/idl_files_list
 idl_attributes_file = $(WebCore)/bindings/scripts/IDLAttributes.txt
 
@@ -410,9 +411,9 @@ $(supplemental_dependency_file): $(SCRIPTS_FOR_PREPROCESS_IDLS) $(dom_binding_id
        $(AM_V_GEN)
        $(AM_V_at)echo -n > $(idl_files_list)
        $(AM_V_at)($(foreach idl, $(dom_binding_idls), echo $(idl) &&) echo -n) >> $(idl_files_list)
-       $(AM_V_at)$(PERL) -I$(WebCore)/bindings/scripts $(WebCore)/bindings/scripts/preprocess-idls.pl --defines "LANGUAGE_JAVASCRIPT=1 $(feature_defines)" --idlFilesList $(idl_files_list) --windowConstructorsFile $(window_constructors_file) --supplementalDependencyFile $@
+       $(AM_V_at)$(PERL) -I$(WebCore)/bindings/scripts $(WebCore)/bindings/scripts/preprocess-idls.pl --defines "LANGUAGE_JAVASCRIPT=1 $(feature_defines)" --idlFilesList $(idl_files_list) --windowConstructorsFile $(window_constructors_file) --workerContextConstructorsFile $(workercontext_constructors_file) --supplementalDependencyFile $@
 
-.PHONY: $(window_constructors_file)
+.PHONY: $(window_constructors_file) $(workercontext_constructors_file)
 
 # This does not appear to work correctly with gnumake unless
 # it includes an empty command list (the semicolon).
@@ -432,7 +433,7 @@ DerivedSources/WebCore/JSInternalSettingsGenerated.h: DerivedSources/WebCore/Int
 # IDL generation takes a long time. The pipe represents an order-only dependency,
 # which means that GNUmake will only try to build the dependencies first, but
 # not rebuild all the targets if the dependencies change.
-$(webkitgtk_sources) $(webkit2_sources) $(webkit2_plugin_process_sources) $(webcore_sources) $(webcoregtk_sources) $(platformgtk_sources) : | $(supplemental_dependency_file) $(window_constructors_file) $(webcore_built_sources)
+$(webkitgtk_sources) $(webkit2_sources) $(webkit2_plugin_process_sources) $(webcore_sources) $(webcoregtk_sources) $(platformgtk_sources) : | $(supplemental_dependency_file) $(window_constructors_file) $(workercontext_constructors_file) $(webcore_built_sources)
 
 noinst_LTLIBRARIES += \
        libWebCorePlatform.la \
index d851687..88c0064 100644 (file)
@@ -295,9 +295,9 @@ endforeach ()
 file(WRITE ${IDL_FILES_TMP} ${IDL_FILES_LIST})
 
 add_custom_command(
-    OUTPUT ${SUPPLEMENTAL_DEPENDENCY_FILE} ${WINDOW_CONSTRUCTORS_FILE}
+    OUTPUT ${SUPPLEMENTAL_DEPENDENCY_FILE} ${WINDOW_CONSTRUCTORS_FILE} ${WORKERCONTEXT_CONSTRUCTORS_FILE}
     DEPENDS ${WEBCORE_DIR}/bindings/scripts/preprocess-idls.pl ${SCRIPTS_RESOLVE_SUPPLEMENTAL} ${WebCore_CPP_IDL_FILES} ${IDL_ATTRIBUTES_FILE}
-    COMMAND ${PERL_EXECUTABLE} -I${WEBCORE_DIR}/bindings/scripts ${WEBCORE_DIR}/bindings/scripts/preprocess-idls.pl --defines "${FEATURE_DEFINES_JAVASCRIPT}" --idlFilesList ${IDL_FILES_TMP} --preprocessor "${CODE_GENERATOR_PREPROCESSOR}" --supplementalDependencyFile ${SUPPLEMENTAL_DEPENDENCY_FILE} --idlAttributesFile ${IDL_ATTRIBUTES_FILE} --windowConstructorsFile ${WINDOW_CONSTRUCTORS_FILE}
+    COMMAND ${PERL_EXECUTABLE} -I${WEBCORE_DIR}/bindings/scripts ${WEBCORE_DIR}/bindings/scripts/preprocess-idls.pl --defines "${FEATURE_DEFINES_JAVASCRIPT}" --idlFilesList ${IDL_FILES_TMP} --preprocessor "${CODE_GENERATOR_PREPROCESSOR}" --supplementalDependencyFile ${SUPPLEMENTAL_DEPENDENCY_FILE} --idlAttributesFile ${IDL_ATTRIBUTES_FILE} --windowConstructorsFile ${WINDOW_CONSTRUCTORS_FILE} --workerContextConstructorsFile ${WORKERCONTEXT_CONSTRUCTORS_FILE}
     VERBATIM)
 
 GENERATE_BINDINGS(WebCore_SOURCES
@@ -307,7 +307,8 @@ GENERATE_BINDINGS(WebCore_SOURCES
     "${FEATURE_DEFINES_WEBCORE}"
     ${DERIVED_SOURCES_WEBCORE_DIR} WebDOM CPP
     ${SUPPLEMENTAL_DEPENDENCY_FILE}
-    ${WINDOW_CONSTRUCTORS_FILE})
+    ${WINDOW_CONSTRUCTORS_FILE}
+    ${WORKERCONTEXT_CONSTRUCTORS_FILE})
 
 # Generate contents for PopupPicker.cpp
 set(WebCore_POPUP_CSS_AND_JS
index aa4f910..07fdb6f 100644 (file)
@@ -304,9 +304,9 @@ list(APPEND WebCoreTestSupport_IDL_FILES ${DERIVED_SOURCES_WEBCORE_DIR}/Internal
 file(WRITE ${IDL_FILES_TMP} ${IDL_FILES_LIST})
 
 add_custom_command(
-    OUTPUT ${SUPPLEMENTAL_DEPENDENCY_FILE} ${WINDOW_CONSTRUCTORS_FILE}
+    OUTPUT ${SUPPLEMENTAL_DEPENDENCY_FILE} ${WINDOW_CONSTRUCTORS_FILE} ${WORKERCONTEXT_CONSTRUCTORS_FILE}
     DEPENDS ${WEBCORE_DIR}/bindings/scripts/preprocess-idls.pl ${SCRIPTS_PREPROCESS_IDLS} ${WebCore_IDL_FILES} ${WebCoreTestSupport_IDL_FILES}
-    COMMAND ${PERL_EXECUTABLE} -I${WEBCORE_DIR}/bindings/scripts ${WEBCORE_DIR}/bindings/scripts/preprocess-idls.pl --defines "${FEATURE_DEFINES_JAVASCRIPT}" --idlFilesList ${IDL_FILES_TMP} --supplementalDependencyFile ${SUPPLEMENTAL_DEPENDENCY_FILE} --windowConstructorsFile ${WINDOW_CONSTRUCTORS_FILE}
+    COMMAND ${PERL_EXECUTABLE} -I${WEBCORE_DIR}/bindings/scripts ${WEBCORE_DIR}/bindings/scripts/preprocess-idls.pl --defines "${FEATURE_DEFINES_JAVASCRIPT}" --idlFilesList ${IDL_FILES_TMP} --supplementalDependencyFile ${SUPPLEMENTAL_DEPENDENCY_FILE} --windowConstructorsFile ${WINDOW_CONSTRUCTORS_FILE} --workerContextConstructorsFile ${WORKERCONTEXT_CONSTRUCTORS_FILE}
     VERBATIM)
 
 GENERATE_BINDINGS(WebCore_SOURCES
@@ -317,7 +317,8 @@ GENERATE_BINDINGS(WebCore_SOURCES
     ${DERIVED_SOURCES_WEBCORE_DIR} JS JS
     ${IDL_ATTRIBUTES_FILE}
     ${SUPPLEMENTAL_DEPENDENCY_FILE}
-    ${WINDOW_CONSTRUCTORS_FILE})
+    ${WINDOW_CONSTRUCTORS_FILE}
+    ${WORKERCONTEXT_CONSTRUCTORS_FILE})
 
 GENERATE_BINDINGS(WebCoreTestSupport_SOURCES
     "${WebCoreTestSupport_IDL_FILES}"
@@ -327,4 +328,5 @@ GENERATE_BINDINGS(WebCoreTestSupport_SOURCES
     ${DERIVED_SOURCES_WEBCORE_DIR} JS JS
     ${IDL_ATTRIBUTES_FILE}
     ${SUPPLEMENTAL_DEPENDENCY_FILE}
-    ${WINDOW_CONSTRUCTORS_FILE})
+    ${WINDOW_CONSTRUCTORS_FILE}
+    ${WORKERCONTEXT_CONSTRUCTORS_FILE})
index edc2735..b065214 100644 (file)
@@ -56,6 +56,7 @@ EnforceRange
 EventTarget
 ExtendsDOMGlobalObject
 GenerateIsReachable=|Impl|ImplContext|ImplDocument|ImplElementRoot|ImplFrame|ImplOwnerNodeRoot
+GlobalContext=WindowOnly|WorkerOnly|WindowAndWorker
 Immutable
 ImplementationLacksVTable
 ImplementationNamespace=*
index cb03860..dcda493 100644 (file)
@@ -29,6 +29,7 @@ my $preprocessor;
 my $idlFilesList;
 my $supplementalDependencyFile;
 my $windowConstructorsFile;
+my $workerContextConstructorsFile;
 my $supplementalMakefileDeps;
 
 GetOptions('defines=s' => \$defines,
@@ -36,11 +37,13 @@ GetOptions('defines=s' => \$defines,
            'idlFilesList=s' => \$idlFilesList,
            'supplementalDependencyFile=s' => \$supplementalDependencyFile,
            'windowConstructorsFile=s' => \$windowConstructorsFile,
+           'workerContextConstructorsFile=s' => \$workerContextConstructorsFile,
            'supplementalMakefileDeps=s' => \$supplementalMakefileDeps);
 
 die('Must specify #define macros using --defines.') unless defined($defines);
 die('Must specify an output file using --supplementalDependencyFile.') unless defined($supplementalDependencyFile);
 die('Must specify an output file using --windowConstructorsFile.') unless defined($windowConstructorsFile);
+die('Must specify an output file using --workerContextConstructorsFile.') unless defined($workerContextConstructorsFile);
 die('Must specify the file listing all IDLs using --idlFilesList.') unless defined($idlFilesList);
 
 open FH, "< $idlFilesList" or die "Cannot open $idlFilesList\n";
@@ -53,7 +56,8 @@ my %interfaceNameToIdlFile;
 my %idlFileToInterfaceName;
 my %supplementalDependencies;
 my %supplementals;
-my $constructorAttributesCode = "";
+my $windowConstructorsCode = "";
+my $workerContextConstructorsCode = "";
 # Get rid of duplicates in idlFiles array.
 my %idlFileHash = map { $_, 1 } @idlFiles;
 foreach my $idlFile (keys %idlFileHash) {
@@ -68,7 +72,10 @@ foreach my $idlFile (keys %idlFileHash) {
     unless (isCallbackInterfaceFromIDL($idlFileContents)) {
         my $extendedAttributes = getInterfaceExtendedAttributesFromIDL($idlFileContents);
         unless ($extendedAttributes->{"NoInterfaceObject"}) {
-            $constructorAttributesCode .= GenerateConstructorAttribute($interfaceName, $extendedAttributes);
+            my $globalContext = $extendedAttributes->{"GlobalContext"} || "WindowOnly";
+            my $attributeCode = GenerateConstructorAttribute($interfaceName, $extendedAttributes);
+            $windowConstructorsCode .= $attributeCode unless $globalContext eq "WorkerOnly";
+            $workerContextConstructorsCode .= $attributeCode unless $globalContext eq "WindowOnly"
         }
     }
     $interfaceNameToIdlFile{$interfaceName} = $fullPath;
@@ -77,13 +84,10 @@ foreach my $idlFile (keys %idlFileHash) {
 }
 
 # Generate DOMWindow Constructors partial interface.
-open PARTIAL_WINDOW_FH, "> $windowConstructorsFile" or die "Cannot open $windowConstructorsFile\n";
-print PARTIAL_WINDOW_FH "partial interface DOMWindow {\n";
-print PARTIAL_WINDOW_FH $constructorAttributesCode;
-print PARTIAL_WINDOW_FH "};\n";
-close PARTIAL_WINDOW_FH;
-my $fullPath = Cwd::realpath($windowConstructorsFile);
-$supplementalDependencies{$fullPath} = "DOMWindow" if $interfaceNameToIdlFile{"DOMWindow"};
+GeneratePartialInterface("DOMWindow", $windowConstructorsCode, $windowConstructorsFile);
+
+# Generate WorkerContext Constructors partial interface.
+GeneratePartialInterface("WorkerContext", $workerContextConstructorsCode, $workerContextConstructorsFile);
 
 # Resolves partial interfaces dependencies.
 foreach my $idlFile (keys %supplementalDependencies) {
@@ -132,6 +136,22 @@ if ($supplementalMakefileDeps) {
     close MAKE_FH;
 }
 
+sub GeneratePartialInterface
+{
+    my $interfaceName = shift;
+    my $attributesCode = shift;
+    my $destinationFile = shift;
+
+    # Generate partial interface for global constructors.
+    open PARTIAL_INTERFACE_FH, "> $destinationFile" or die "Cannot open $destinationFile\n";
+    print PARTIAL_INTERFACE_FH "partial interface ${interfaceName} {\n";
+    print PARTIAL_INTERFACE_FH $attributesCode;
+    print PARTIAL_INTERFACE_FH "};\n";
+    close PARTIAL_INTERFACE_FH;
+    my $fullPath = Cwd::realpath($destinationFile);
+    $supplementalDependencies{$fullPath} = $interfaceName if $interfaceNameToIdlFile{$interfaceName};
+}
+
 sub GenerateConstructorAttribute
 {
     my $interfaceName = shift;
index 55a5269..9b5d40c 100644 (file)
@@ -26,6 +26,7 @@
  */
 
 [
+    GlobalContext=WindowAndWorker,
     JSNoStaticTables,
     ConstructorTemplate=Event
 ] interface MessageEvent : Event {
index 1c606c4..cf09f18 100644 (file)
@@ -29,6 +29,7 @@
  */
 
 [
+    GlobalContext=WindowAndWorker,
     GenerateIsReachable=Impl,
     CustomToJSObject,
     JSNoStaticTables,
index 7d192a5..9bb3c95 100644 (file)
@@ -30,6 +30,7 @@
  */
 
 [
+    GlobalContext=WindowAndWorker,
     Conditional=BLOB,
     ActiveDOMObject,
     Constructor,
index deb137a..94f37f7 100644 (file)
@@ -29,7 +29,7 @@
  */
 
 [
-    NoInterfaceObject,
+    GlobalContext=WorkerOnly,
     Conditional=BLOB,
     Constructor,
     JSNoStaticTables
index dc76d55..94da535 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 [
+    GlobalContext=WindowAndWorker,
     Conditional=BLOB,
     Constructor,
     JSGenerateToNativeObject,
index 1d800cd..e237861 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 [
+    GlobalContext=WindowAndWorker,
     GenerateIsReachable=Impl,
     CustomConstructor(unsigned long length),
     JSNoStaticTables,
index 470b745..2c777fa 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 [
+    GlobalContext=WindowAndWorker,
     CustomConstructor(ArrayBuffer buffer, optional unsigned long byteOffset, optional unsigned long byteLength),
     CustomToJSObject,
     JSNoStaticTables
index f102081..fa01c98 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 [
+    GlobalContext=WindowAndWorker,
     ConstructorTemplate=TypedArray,
     NumericIndexedGetter,
     CustomIndexedSetter,
index 9b30a2b..c95be13 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 [
+    GlobalContext=WindowAndWorker,
     ConstructorTemplate=TypedArray,
     NumericIndexedGetter,
     CustomIndexedSetter,
index b246225..c76519a 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 [
+    GlobalContext=WindowAndWorker,
     ConstructorTemplate=TypedArray,
     NumericIndexedGetter,
     CustomIndexedSetter,
index c721030..1ee441c 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 [
+    GlobalContext=WindowAndWorker,
     ConstructorTemplate=TypedArray,
     NumericIndexedGetter,
     CustomIndexedSetter,
index 2ac1dcc..035e8c4 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 [
+    GlobalContext=WindowAndWorker,
     ConstructorTemplate=TypedArray,
     NumericIndexedGetter,
     CustomIndexedSetter,
index cd05689..06c8d5d 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 [
+    GlobalContext=WindowAndWorker,
     ConstructorTemplate=TypedArray,
     NumericIndexedGetter,
     CustomIndexedSetter,
index 2a16be1..775cc24 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 [
+    GlobalContext=WindowAndWorker,
     ConstructorTemplate=TypedArray,
     NumericIndexedGetter,
     CustomIndexedSetter,
index 917d684..3a417a5 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 [
+    GlobalContext=WindowAndWorker,
     ConstructorTemplate=TypedArray,
     NumericIndexedGetter,
     CustomIndexedSetter,
index c2d8b37..346dd1f 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 [
+    GlobalContext=WindowAndWorker,
     ConstructorTemplate=TypedArray,
     NumericIndexedGetter,
     CustomIndexedSetter,
index c9515cf..408927a 100644 (file)
 
 #if !defined(LANGUAGE_CPP) || !LANGUAGE_CPP
     // Constructors
-    attribute MessageEventConstructor MessageEvent;
-    attribute WorkerLocationConstructor WorkerLocation;
-
     [Conditional=CHANNEL_MESSAGING, CustomGetter] attribute MessageChannelConstructor MessageChannel;
     [CustomGetter] attribute EventSourceConstructor EventSource;
     [CustomGetter] attribute XMLHttpRequestConstructor XMLHttpRequest;
 #endif
 
-#if defined(ENABLE_BLOB) && ENABLE_BLOB
-    attribute BlobConstructor Blob;
-    attribute FileReaderConstructor FileReader;
-    attribute FileReaderSyncConstructor FileReaderSync;
-#endif
-
-    [Conditional=BLOB] attribute DOMURLConstructor URL;
     [Conditional=BLOB] attribute DOMURLConstructor webkitURL; // FIXME: deprecate this.
-
-    attribute ArrayBufferConstructor ArrayBuffer; // Usable with new operator
-    attribute Int8ArrayConstructor Int8Array; // Usable with new operator
-    attribute Uint8ArrayConstructor Uint8Array; // Usable with new operator
-    attribute Uint8ClampedArrayConstructor Uint8ClampedArray; // Usable with new operator
-    attribute Int16ArrayConstructor Int16Array; // Usable with new operator
-    attribute Uint16ArrayConstructor Uint16Array; // Usable with new operator
-    attribute Int32ArrayConstructor Int32Array; // Usable with new operator
-    attribute Uint32ArrayConstructor Uint32Array; // Usable with new operator
-    attribute Float32ArrayConstructor Float32Array; // Usable with new operator
-    attribute Float64ArrayConstructor Float64Array; // Usable with new operator
-    attribute DataViewConstructor DataView; // Usable with new operator
 };
 
index 58442d3..23e12b8 100644 (file)
@@ -27,7 +27,7 @@
  */
 
 [
-    NoInterfaceObject,
+    GlobalContext=WorkerOnly,
     Conditional=WORKERS,
     GenerateIsReachable=Impl,
     JSNoStaticTables,
index 8d49361..7f3687e 100644 (file)
@@ -38,12 +38,13 @@ macro(GENERATE_BINDINGS _output_source _input_files _base_dir _idl_includes _fea
     set(BINDING_GENERATOR ${WEBCORE_DIR}/bindings/scripts/generate-bindings.pl)
     set(_args ${ARGN})
     list(LENGTH _args _argCount)
-    if (_argCount EQUAL 2)
+    if (_argCount EQUAL 3)
         list(GET _args 0 _supplemental_dependency_file)
         if (_supplemental_dependency_file)
             set(_supplemental_dependency --supplementalDependencyFile ${_supplemental_dependency_file})
         endif ()
         list(GET _args 1 _window_constructors_file)
+        list(GET _args 2 _workercontext_constructors_file)
     endif ()
 
     foreach (_file ${_input_files})
@@ -52,7 +53,7 @@ macro(GENERATE_BINDINGS _output_source _input_files _base_dir _idl_includes _fea
         add_custom_command(
             OUTPUT ${_destination}/${_prefix}${_name}.cpp ${_destination}/${_prefix}${_name}.h
             MAIN_DEPENDENCY ${_file}
-            DEPENDS ${BINDING_GENERATOR} ${SCRIPTS_BINDINGS} ${_supplemental_dependency_file} ${_idl_attributes_file} ${_window_constructors_file}
+            DEPENDS ${BINDING_GENERATOR} ${SCRIPTS_BINDINGS} ${_supplemental_dependency_file} ${_idl_attributes_file} ${_window_constructors_file} ${_workercontext_constructors_file}
             COMMAND ${PERL_EXECUTABLE} -I${WEBCORE_DIR}/bindings/scripts ${BINDING_GENERATOR} --defines "${_features}" --generator ${_generator} ${_idl_includes} --outputDir "${_destination}" --preprocessor "${CODE_GENERATOR_PREPROCESSOR}" --idlAttributesFile ${_idl_attributes_file} ${_supplemental_dependency} ${_file}
             WORKING_DIRECTORY ${_base_dir}
             VERBATIM)
index ea15674..c5f2f60 100644 (file)
@@ -1,3 +1,17 @@
+2013-06-04  Christophe Dumez  <ch.dumez@sisa.samsung.com>
+
+        Automatically generate WorkerContext constructor attributes
+        https://bugs.webkit.org/show_bug.cgi?id=117183
+
+        Reviewed by Kentaro Hara.
+
+        Pass new --workerContextConstructorsFile to preprocess-idl.pl for bindings
+        tests.
+
+        * Scripts/webkitpy/bindings/main.py:
+        (BindingsTests.generate_supplemental_dependency):
+        (BindingsTests.main):
+
 2013-06-04  Ryuan Choi  <ryuan.choi@samsung.com>
 
         [EFL] File dialog of MiniBrowser have broken background.
index 4f0fa0e..92f9987 100644 (file)
@@ -61,7 +61,7 @@ class BindingsTests:
             exit_code = e.exit_code
         return exit_code
 
-    def generate_supplemental_dependency(self, input_directory, supplemental_dependency_file, window_constructors_file):
+    def generate_supplemental_dependency(self, input_directory, supplemental_dependency_file, window_constructors_file, workercontext_constructors_file):
         idl_files_list = tempfile.mkstemp()
         for input_file in os.listdir(input_directory):
             (name, extension) = os.path.splitext(input_file)
@@ -76,7 +76,8 @@ class BindingsTests:
                '--idlFilesList', idl_files_list[1],
                '--defines', '',
                '--supplementalDependencyFile', supplemental_dependency_file,
-               '--windowConstructorsFile', window_constructors_file]
+               '--windowConstructorsFile', window_constructors_file,
+               '--workerContextConstructorsFile', workercontext_constructors_file]
 
         exit_code = 0
         try:
@@ -152,7 +153,8 @@ class BindingsTests:
         input_directory = os.path.join('WebCore', 'bindings', 'scripts', 'test')
         supplemental_dependency_file = tempfile.mkstemp()[1]
         window_constructors_file = tempfile.mkstemp()[1]
-        if self.generate_supplemental_dependency(input_directory, supplemental_dependency_file, window_constructors_file):
+        workercontext_constructors_file = tempfile.mkstemp()[1]
+        if self.generate_supplemental_dependency(input_directory, supplemental_dependency_file, window_constructors_file, workercontext_constructors_file):
             print 'Failed to generate a supplemental dependency file.'
             os.remove(supplemental_dependency_file)
             return -1