Title: [202551] trunk/Source/WebCore
Revision
202551
Author
[email protected]
Date
2016-06-28 00:04:55 -0700 (Tue, 28 Jun 2016)

Log Message

Binding generator should generate accessors for constructors safely accessed from JS builtin
https://bugs.webkit.org/show_bug.cgi?id=159087

Patch by Youenn Fablet <[email protected]> on 2016-06-28
Reviewed by Alex Christensen.

Removed constructor private slots direct additions in JSDOMGlobalObject.
Added support for generating the code that will do that.
Advantage of the implementation:
- Private slots will expose constructors that are also publically visible (previously workers had some private slots filled with WebRTC constructors).
- Private slots no longer require the creation of the constructors at window creation time.

Although PublicIdentifier and PrivateIdentifier are both added where needed, the binding generator does not
support the case of a constructor accessible only privately.

Covered by existing test set and adding binding test.

* Modules/mediastream/MediaStream.idl: Marked as PublicIdentifier/PrivateIdentifier.
* Modules/mediastream/MediaStreamTrack.idl: Ditto.
* Modules/mediastream/RTCIceCandidate.idl: Ditto.
* Modules/mediastream/RTCSessionDescription.idl: Ditto.
* Modules/streams/ReadableStream.idl: Ditto.
* bindings/js/JSDOMGlobalObject.cpp:
(WebCore::JSDOMGlobalObject::addBuiltinGlobals): Removed unneeded additions.
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation): Added support for private slots for interface constructors marked as
PrivateIdentifier.
* bindings/scripts/preprocess-idls.pl:
(GenerateConstructorAttribute): Make PublicIdentifier/PrivateIdentifier copied interface attributes.
* bindings/scripts/test/GObject/WebKitDOMTestGlobalObject.cpp:
(webkit_dom_test_global_object_set_property):
(webkit_dom_test_global_object_get_property):
(webkit_dom_test_global_object_class_init):
(webkit_dom_test_global_object_get_public_and_private_attribute):
(webkit_dom_test_global_object_set_public_and_private_attribute):
* bindings/scripts/test/GObject/WebKitDOMTestGlobalObject.h:
* bindings/scripts/test/JS/JSTestGlobalObject.cpp:
(WebCore::JSTestGlobalObject::finishCreation):
(WebCore::jsTestGlobalObjectPublicAndPrivateAttribute):
(WebCore::setJSTestGlobalObjectPublicAndPrivateAttribute):
* bindings/scripts/test/ObjC/DOMTestGlobalObject.h:
* bindings/scripts/test/ObjC/DOMTestGlobalObject.mm:
(-[DOMTestGlobalObject publicAndPrivateAttribute]):
(-[DOMTestGlobalObject setPublicAndPrivateAttribute:]):
* bindings/scripts/test/TestGlobalObject.idl:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (202550 => 202551)


--- trunk/Source/WebCore/ChangeLog	2016-06-28 07:03:16 UTC (rev 202550)
+++ trunk/Source/WebCore/ChangeLog	2016-06-28 07:04:55 UTC (rev 202551)
@@ -1,3 +1,51 @@
+2016-06-28  Youenn Fablet  <[email protected]>
+
+        Binding generator should generate accessors for constructors safely accessed from JS builtin
+        https://bugs.webkit.org/show_bug.cgi?id=159087
+
+        Reviewed by Alex Christensen.
+
+        Removed constructor private slots direct additions in JSDOMGlobalObject.
+        Added support for generating the code that will do that.
+        Advantage of the implementation:
+        - Private slots will expose constructors that are also publically visible (previously workers had some private slots filled with WebRTC constructors).
+        - Private slots no longer require the creation of the constructors at window creation time.
+
+        Although PublicIdentifier and PrivateIdentifier are both added where needed, the binding generator does not
+        support the case of a constructor accessible only privately.
+
+        Covered by existing test set and adding binding test.
+
+        * Modules/mediastream/MediaStream.idl: Marked as PublicIdentifier/PrivateIdentifier.
+        * Modules/mediastream/MediaStreamTrack.idl: Ditto.
+        * Modules/mediastream/RTCIceCandidate.idl: Ditto.
+        * Modules/mediastream/RTCSessionDescription.idl: Ditto.
+        * Modules/streams/ReadableStream.idl: Ditto.
+        * bindings/js/JSDOMGlobalObject.cpp:
+        (WebCore::JSDOMGlobalObject::addBuiltinGlobals): Removed unneeded additions.
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateImplementation): Added support for private slots for interface constructors marked as
+        PrivateIdentifier.
+        * bindings/scripts/preprocess-idls.pl:
+        (GenerateConstructorAttribute): Make PublicIdentifier/PrivateIdentifier copied interface attributes.
+        * bindings/scripts/test/GObject/WebKitDOMTestGlobalObject.cpp:
+        (webkit_dom_test_global_object_set_property):
+        (webkit_dom_test_global_object_get_property):
+        (webkit_dom_test_global_object_class_init):
+        (webkit_dom_test_global_object_get_public_and_private_attribute):
+        (webkit_dom_test_global_object_set_public_and_private_attribute):
+        * bindings/scripts/test/GObject/WebKitDOMTestGlobalObject.h:
+        * bindings/scripts/test/JS/JSTestGlobalObject.cpp:
+        (WebCore::JSTestGlobalObject::finishCreation):
+        (WebCore::jsTestGlobalObjectPublicAndPrivateAttribute):
+        (WebCore::setJSTestGlobalObjectPublicAndPrivateAttribute):
+        * bindings/scripts/test/ObjC/DOMTestGlobalObject.h:
+        * bindings/scripts/test/ObjC/DOMTestGlobalObject.mm:
+        (-[DOMTestGlobalObject publicAndPrivateAttribute]):
+        (-[DOMTestGlobalObject setPublicAndPrivateAttribute:]):
+        * bindings/scripts/test/TestGlobalObject.idl:
+
+
 2016-06-27  Jer Noble  <[email protected]>
 
         REGRESSION?(r202466): http/tests/security/canvas-remote-read-remote-video-redirect.html failing on Sierra

Modified: trunk/Source/WebCore/Modules/mediastream/MediaStream.idl (202550 => 202551)


--- trunk/Source/WebCore/Modules/mediastream/MediaStream.idl	2016-06-28 07:03:16 UTC (rev 202550)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStream.idl	2016-06-28 07:04:55 UTC (rev 202551)
@@ -28,6 +28,8 @@
     Constructor(MediaStream stream),
     Constructor(MediaStreamTrack[] tracks),
     ConstructorCallWith=ScriptExecutionContext,
+    PrivateIdentifier,
+    PublicIdentifier
 ] interface MediaStream : EventTarget {
 
     readonly attribute DOMString id;

Modified: trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.idl (202550 => 202551)


--- trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.idl	2016-06-28 07:03:16 UTC (rev 202550)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.idl	2016-06-28 07:04:55 UTC (rev 202551)
@@ -29,6 +29,8 @@
     Conditional=MEDIA_STREAM,
     ActiveDOMObject,
     SkipVTableValidation,
+    PrivateIdentifier,
+    PublicIdentifier
 ] interface MediaStreamTrack : EventTarget {
     readonly attribute DOMString kind;
     readonly attribute DOMString id;

Modified: trunk/Source/WebCore/Modules/mediastream/RTCIceCandidate.idl (202550 => 202551)


--- trunk/Source/WebCore/Modules/mediastream/RTCIceCandidate.idl	2016-06-28 07:03:16 UTC (rev 202550)
+++ trunk/Source/WebCore/Modules/mediastream/RTCIceCandidate.idl	2016-06-28 07:04:55 UTC (rev 202551)
@@ -32,7 +32,9 @@
 [
     Conditional=WEB_RTC,
     Constructor(Dictionary dictionary),
-    ConstructorRaisesException
+    ConstructorRaisesException,
+    PrivateIdentifier,
+    PublicIdentifier
 ] interface RTCIceCandidate {
     readonly attribute DOMString candidate;
     readonly attribute DOMString? sdpMid;

Modified: trunk/Source/WebCore/Modules/mediastream/RTCSessionDescription.idl (202550 => 202551)


--- trunk/Source/WebCore/Modules/mediastream/RTCSessionDescription.idl	2016-06-28 07:03:16 UTC (rev 202550)
+++ trunk/Source/WebCore/Modules/mediastream/RTCSessionDescription.idl	2016-06-28 07:04:55 UTC (rev 202551)
@@ -32,7 +32,9 @@
 [
     Conditional=WEB_RTC,
     Constructor(Dictionary dictionary),
-    ConstructorRaisesException
+    ConstructorRaisesException,
+    PrivateIdentifier,
+    PublicIdentifier
 ] interface RTCSessionDescription {
     [SetterRaisesException] readonly attribute RTCSdpType type;
     readonly attribute DOMString sdp;

Modified: trunk/Source/WebCore/Modules/streams/ReadableStream.idl (202550 => 202551)


--- trunk/Source/WebCore/Modules/streams/ReadableStream.idl	2016-06-28 07:03:16 UTC (rev 202550)
+++ trunk/Source/WebCore/Modules/streams/ReadableStream.idl	2016-06-28 07:04:55 UTC (rev 202551)
@@ -31,7 +31,9 @@
     Conditional=STREAMS_API,
     Constructor,
     Exposed=(Window,Worker),
-    JSBuiltin
+    JSBuiltin,
+    PrivateIdentifier,
+    PublicIdentifier
 ] interface ReadableStream {
     Promise cancel(optional any reason);
     Object getReader();

Modified: trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp (202550 => 202551)


--- trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp	2016-06-28 07:03:16 UTC (rev 202550)
+++ trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp	2016-06-28 07:04:55 UTC (rev 202551)
@@ -83,19 +83,8 @@
         JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().streamReadablePrivateName(), jsNumber(4), DontDelete | ReadOnly),
         JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().streamWaitingPrivateName(), jsNumber(5), DontDelete | ReadOnly),
         JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().streamWritablePrivateName(), jsNumber(6), DontDelete | ReadOnly),
-#if ENABLE(MEDIA_STREAM)
-        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().MediaStreamPrivateName(), JSMediaStream::getConstructor(vm, this), DontDelete | ReadOnly),
-        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().MediaStreamTrackPrivateName(), JSMediaStreamTrack::getConstructor(vm, this), DontDelete | ReadOnly),
-#endif
-#if ENABLE(STREAMS_API)
-        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().ReadableStreamPrivateName(), JSReadableStream::getConstructor(vm, this), DontDelete | ReadOnly),
-#endif
         JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().ReadableStreamControllerPrivateName(), privateReadableStreamControllerConstructor, DontDelete | ReadOnly),
         JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().ReadableStreamReaderPrivateName(), privateReadableStreamReaderConstructor, DontDelete | ReadOnly),
-#if ENABLE(WEB_RTC)
-        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().RTCIceCandidatePrivateName(), JSRTCIceCandidate::getConstructor(vm, this), DontDelete | ReadOnly),
-        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().RTCSessionDescriptionPrivateName(), JSRTCSessionDescription::getConstructor(vm, this), DontDelete | ReadOnly),
-#endif
     };
     addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals));
 #endif

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (202550 => 202551)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-06-28 07:03:16 UTC (rev 202550)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-06-28 07:04:55 UTC (rev 202551)
@@ -2393,6 +2393,21 @@
             push(@implContent, "    }\n");
             push(@implContent, "#endif\n") if $conditionalString;
         }
+
+        # Support PrivateIdentifier attributes on global objects
+        foreach my $attribute (@{$interface->attributes}) {
+            next unless $attribute->signature->extendedAttributes->{"PrivateIdentifier"};
+
+            AddToImplIncludes("WebCoreJSClientData.h");
+            my $conditionalString = $codeGenerator->GenerateConditionalString($attribute->signature);
+            my $attributeName = $attribute->signature->name;
+            my $getter = GetAttributeGetterName($interface, $className, $attribute);
+
+            push(@implContent, "#if ${conditionalString}\n") if $conditionalString;
+            push(@implContent, "    putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames()." . $attributeName . "PrivateName(), CustomGetterSetter::create(vm, $getter, nullptr), attributesForStructure(DontDelete | ReadOnly));\n");
+            push(@implContent, "#endif\n") if $conditionalString;
+        }
+
         # Support for RuntimeEnabled operations on global objects.
         foreach my $function (@{$interface->functions}) {
             next unless $function->signature->extendedAttributes->{"EnabledAtRuntime"};

Modified: trunk/Source/WebCore/bindings/scripts/preprocess-idls.pl (202550 => 202551)


--- trunk/Source/WebCore/bindings/scripts/preprocess-idls.pl	2016-06-28 07:03:16 UTC (rev 202550)
+++ trunk/Source/WebCore/bindings/scripts/preprocess-idls.pl	2016-06-28 07:04:55 UTC (rev 202551)
@@ -238,7 +238,7 @@
     my $code = "    ";
     my @extendedAttributesList;
     foreach my $attributeName (sort keys %{$extendedAttributes}) {
-      next unless ($attributeName eq "Conditional" || $attributeName eq "EnabledAtRuntime" || $attributeName eq "EnabledBySetting");
+      next unless ($attributeName eq "Conditional" || $attributeName eq "EnabledAtRuntime" || $attributeName eq "EnabledBySetting" || $attributeName eq "PrivateIdentifier" || $attributeName eq "PublicIdentifier");
       my $extendedAttribute = $attributeName;
       $extendedAttribute .= "=" . $extendedAttributes->{$attributeName} unless $extendedAttributes->{$attributeName} eq "VALUE_IS_MISSING";
       push(@extendedAttributesList, $extendedAttribute);

Modified: trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestGlobalObject.cpp (202550 => 202551)


--- trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestGlobalObject.cpp	2016-06-28 07:03:16 UTC (rev 202550)
+++ trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestGlobalObject.cpp	2016-06-28 07:04:55 UTC (rev 202551)
@@ -70,6 +70,8 @@
 enum {
     PROP_0,
     PROP_REGULAR_ATTRIBUTE,
+    PROP_PUBLIC_AND_PRIVATE_ATTRIBUTE,
+    PROP_PUBLIC_AND_PRIVATE_CONDITIONAL_ATTRIBUTE,
     PROP_ENABLED_AT_RUNTIME_ATTRIBUTE,
 };
 
@@ -91,6 +93,12 @@
     case PROP_REGULAR_ATTRIBUTE:
         webkit_dom_test_global_object_set_regular_attribute(self, g_value_get_string(value));
         break;
+    case PROP_PUBLIC_AND_PRIVATE_ATTRIBUTE:
+        webkit_dom_test_global_object_set_public_and_private_attribute(self, g_value_get_string(value));
+        break;
+    case PROP_PUBLIC_AND_PRIVATE_CONDITIONAL_ATTRIBUTE:
+        webkit_dom_test_global_object_set_public_and_private_conditional_attribute(self, g_value_get_string(value));
+        break;
     case PROP_ENABLED_AT_RUNTIME_ATTRIBUTE:
         webkit_dom_test_global_object_set_enabled_at_runtime_attribute(self, g_value_get_string(value));
         break;
@@ -108,6 +116,12 @@
     case PROP_REGULAR_ATTRIBUTE:
         g_value_take_string(value, webkit_dom_test_global_object_get_regular_attribute(self));
         break;
+    case PROP_PUBLIC_AND_PRIVATE_ATTRIBUTE:
+        g_value_take_string(value, webkit_dom_test_global_object_get_public_and_private_attribute(self));
+        break;
+    case PROP_PUBLIC_AND_PRIVATE_CONDITIONAL_ATTRIBUTE:
+        g_value_take_string(value, webkit_dom_test_global_object_get_public_and_private_conditional_attribute(self));
+        break;
     case PROP_ENABLED_AT_RUNTIME_ATTRIBUTE:
         g_value_take_string(value, webkit_dom_test_global_object_get_enabled_at_runtime_attribute(self));
         break;
@@ -149,6 +163,26 @@
 
     g_object_class_install_property(
         gobjectClass,
+        PROP_PUBLIC_AND_PRIVATE_ATTRIBUTE,
+        g_param_spec_string(
+            "public-and-private-attribute",
+            "TestGlobalObject:public-and-private-attribute",
+            "read-write gchar* TestGlobalObject:public-and-private-attribute",
+            "",
+            WEBKIT_PARAM_READWRITE));
+
+    g_object_class_install_property(
+        gobjectClass,
+        PROP_PUBLIC_AND_PRIVATE_CONDITIONAL_ATTRIBUTE,
+        g_param_spec_string(
+            "public-and-private-conditional-attribute",
+            "TestGlobalObject:public-and-private-conditional-attribute",
+            "read-write gchar* TestGlobalObject:public-and-private-conditional-attribute",
+            "",
+            WEBKIT_PARAM_READWRITE));
+
+    g_object_class_install_property(
+        gobjectClass,
         PROP_ENABLED_AT_RUNTIME_ATTRIBUTE,
         g_param_spec_string(
             "enabled-at-runtime-attribute",
@@ -224,6 +258,56 @@
     item->setRegularAttribute(convertedValue);
 }
 
+gchar* webkit_dom_test_global_object_get_public_and_private_attribute(WebKitDOMTestGlobalObject* self)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_val_if_fail(WEBKIT_DOM_IS_TEST_GLOBAL_OBJECT(self), 0);
+    WebCore::TestGlobalObject* item = WebKit::core(self);
+    gchar* result = convertToUTF8String(item->publicAndPrivateAttribute());
+    return result;
+}
+
+void webkit_dom_test_global_object_set_public_and_private_attribute(WebKitDOMTestGlobalObject* self, const gchar* value)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_if_fail(WEBKIT_DOM_IS_TEST_GLOBAL_OBJECT(self));
+    g_return_if_fail(value);
+    WebCore::TestGlobalObject* item = WebKit::core(self);
+    WTF::String convertedValue = WTF::String::fromUTF8(value);
+    item->setPublicAndPrivateAttribute(convertedValue);
+}
+
+gchar* webkit_dom_test_global_object_get_public_and_private_conditional_attribute(WebKitDOMTestGlobalObject* self)
+{
+#if ENABLE(TEST_FEATURE)
+    WebCore::JSMainThreadNullState state;
+    g_return_val_if_fail(WEBKIT_DOM_IS_TEST_GLOBAL_OBJECT(self), 0);
+    WebCore::TestGlobalObject* item = WebKit::core(self);
+    gchar* result = convertToUTF8String(item->publicAndPrivateConditionalAttribute());
+    return result;
+#else
+    UNUSED_PARAM(self);
+    WEBKIT_WARN_FEATURE_NOT_PRESENT("Test Feature")
+    return 0;
+#endif /* ENABLE(TEST_FEATURE) */
+}
+
+void webkit_dom_test_global_object_set_public_and_private_conditional_attribute(WebKitDOMTestGlobalObject* self, const gchar* value)
+{
+#if ENABLE(TEST_FEATURE)
+    WebCore::JSMainThreadNullState state;
+    g_return_if_fail(WEBKIT_DOM_IS_TEST_GLOBAL_OBJECT(self));
+    g_return_if_fail(value);
+    WebCore::TestGlobalObject* item = WebKit::core(self);
+    WTF::String convertedValue = WTF::String::fromUTF8(value);
+    item->setPublicAndPrivateConditionalAttribute(convertedValue);
+#else
+    UNUSED_PARAM(self);
+    UNUSED_PARAM(value);
+    WEBKIT_WARN_FEATURE_NOT_PRESENT("Test Feature")
+#endif /* ENABLE(TEST_FEATURE) */
+}
+
 gchar* webkit_dom_test_global_object_get_enabled_at_runtime_attribute(WebKitDOMTestGlobalObject* self)
 {
 #if ENABLE(TEST_FEATURE)

Modified: trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestGlobalObject.h (202550 => 202551)


--- trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestGlobalObject.h	2016-06-28 07:03:16 UTC (rev 202550)
+++ trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestGlobalObject.h	2016-06-28 07:04:55 UTC (rev 202551)
@@ -99,6 +99,48 @@
 webkit_dom_test_global_object_set_regular_attribute(WebKitDOMTestGlobalObject* self, const gchar* value);
 
 /**
+ * webkit_dom_test_global_object_get_public_and_private_attribute:
+ * @self: A #WebKitDOMTestGlobalObject
+ *
+ * Returns: A #gchar
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API gchar*
+webkit_dom_test_global_object_get_public_and_private_attribute(WebKitDOMTestGlobalObject* self);
+
+/**
+ * webkit_dom_test_global_object_set_public_and_private_attribute:
+ * @self: A #WebKitDOMTestGlobalObject
+ * @value: A #gchar
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API void
+webkit_dom_test_global_object_set_public_and_private_attribute(WebKitDOMTestGlobalObject* self, const gchar* value);
+
+/**
+ * webkit_dom_test_global_object_get_public_and_private_conditional_attribute:
+ * @self: A #WebKitDOMTestGlobalObject
+ *
+ * Returns: A #gchar
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API gchar*
+webkit_dom_test_global_object_get_public_and_private_conditional_attribute(WebKitDOMTestGlobalObject* self);
+
+/**
+ * webkit_dom_test_global_object_set_public_and_private_conditional_attribute:
+ * @self: A #WebKitDOMTestGlobalObject
+ * @value: A #gchar
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API void
+webkit_dom_test_global_object_set_public_and_private_conditional_attribute(WebKitDOMTestGlobalObject* self, const gchar* value);
+
+/**
  * webkit_dom_test_global_object_get_enabled_at_runtime_attribute:
  * @self: A #WebKitDOMTestGlobalObject
  *

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp (202550 => 202551)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp	2016-06-28 07:03:16 UTC (rev 202550)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp	2016-06-28 07:04:55 UTC (rev 202551)
@@ -27,6 +27,7 @@
 #include "JSDOMConvert.h"
 #include "RuntimeEnabledFeatures.h"
 #include "URL.h"
+#include "WebCoreJSClientData.h"
 #include <runtime/Error.h>
 #include <runtime/FunctionPrototype.h>
 #include <runtime/JSString.h>
@@ -47,7 +48,13 @@
 
 JSC::EncodedJSValue jsTestGlobalObjectRegularAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
 bool setJSTestGlobalObjectRegularAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
+JSC::EncodedJSValue jsTestGlobalObjectPublicAndPrivateAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
+bool setJSTestGlobalObjectPublicAndPrivateAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 #if ENABLE(TEST_FEATURE)
+JSC::EncodedJSValue jsTestGlobalObjectPublicAndPrivateConditionalAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
+bool setJSTestGlobalObjectPublicAndPrivateConditionalAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
+#endif
+#if ENABLE(TEST_FEATURE)
 JSC::EncodedJSValue jsTestGlobalObjectEnabledAtRuntimeAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
 bool setJSTestGlobalObjectEnabledAtRuntimeAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 #endif
@@ -58,15 +65,23 @@
 
 /* Hash table */
 
-static const struct CompactHashIndex JSTestGlobalObjectTableIndex[8] = {
+static const struct CompactHashIndex JSTestGlobalObjectTableIndex[16] = {
     { -1, -1 },
-    { 1, -1 },
     { -1, -1 },
+    { 2, -1 },
     { 0, -1 },
     { -1, -1 },
     { -1, -1 },
     { -1, -1 },
     { -1, -1 },
+    { -1, -1 },
+    { 3, -1 },
+    { -1, -1 },
+    { -1, -1 },
+    { -1, -1 },
+    { -1, -1 },
+    { 1, -1 },
+    { -1, -1 },
 };
 
 
@@ -73,10 +88,16 @@
 static const HashTableValue JSTestGlobalObjectTableValues[] =
 {
     { "regularAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGlobalObjectRegularAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGlobalObjectRegularAttribute) } },
+    { "publicAndPrivateAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGlobalObjectPublicAndPrivateAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGlobalObjectPublicAndPrivateAttribute) } },
+#if ENABLE(TEST_FEATURE)
+    { "publicAndPrivateConditionalAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGlobalObjectPublicAndPrivateConditionalAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGlobalObjectPublicAndPrivateConditionalAttribute) } },
+#else
+    { 0, 0, NoIntrinsic, { 0, 0 } },
+#endif
     { "regularOperation", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestGlobalObjectInstanceFunctionRegularOperation), (intptr_t) (1) } },
 };
 
-static const HashTable JSTestGlobalObjectTable = { 2, 7, true, JSTestGlobalObjectTableValues, JSTestGlobalObjectTableIndex };
+static const HashTable JSTestGlobalObjectTable = { 4, 15, true, JSTestGlobalObjectTableValues, JSTestGlobalObjectTableIndex };
 template<> JSValue JSTestGlobalObjectConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
 {
     UNUSED_PARAM(vm);
@@ -125,7 +146,11 @@
         putDirectCustomAccessor(vm, vm.propertyNames->enabledAtRuntimeAttribute, customGetterSetter, attributesForStructure(CustomAccessor));
     }
 #endif
+    putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().publicAndPrivateAttributePrivateName(), CustomGetterSetter::create(vm, jsTestGlobalObjectPublicAndPrivateAttribute, nullptr), attributesForStructure(DontDelete | ReadOnly));
 #if ENABLE(TEST_FEATURE)
+    putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().publicAndPrivateConditionalAttributePrivateName(), CustomGetterSetter::create(vm, jsTestGlobalObjectPublicAndPrivateConditionalAttribute, nullptr), attributesForStructure(DontDelete | ReadOnly));
+#endif
+#if ENABLE(TEST_FEATURE)
     if (RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled())
         putDirectNativeFunction(vm, this, vm.propertyNames->enabledAtRuntimeOperation, 1, jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation, NoIntrinsic, attributesForStructure(JSC::Function));
 #endif
@@ -152,7 +177,39 @@
 }
 
 
+EncodedJSValue jsTestGlobalObjectPublicAndPrivateAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
+{
+    UNUSED_PARAM(state);
+    UNUSED_PARAM(thisValue);
+    JSValue decodedThisValue = JSValue::decode(thisValue);
+    auto* castedThis = jsDynamicCast<JSTestGlobalObject*>(decodedThisValue);
+    if (UNLIKELY(!castedThis)) {
+        return throwGetterTypeError(*state, "TestGlobalObject", "publicAndPrivateAttribute");
+    }
+    auto& impl = castedThis->wrapped();
+    JSValue result = jsStringWithCache(state, impl.publicAndPrivateAttribute());
+    return JSValue::encode(result);
+}
+
+
 #if ENABLE(TEST_FEATURE)
+EncodedJSValue jsTestGlobalObjectPublicAndPrivateConditionalAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
+{
+    UNUSED_PARAM(state);
+    UNUSED_PARAM(thisValue);
+    JSValue decodedThisValue = JSValue::decode(thisValue);
+    auto* castedThis = jsDynamicCast<JSTestGlobalObject*>(decodedThisValue);
+    if (UNLIKELY(!castedThis)) {
+        return throwGetterTypeError(*state, "TestGlobalObject", "publicAndPrivateConditionalAttribute");
+    }
+    auto& impl = castedThis->wrapped();
+    JSValue result = jsStringWithCache(state, impl.publicAndPrivateConditionalAttribute());
+    return JSValue::encode(result);
+}
+
+#endif
+
+#if ENABLE(TEST_FEATURE)
 EncodedJSValue jsTestGlobalObjectEnabledAtRuntimeAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
 {
     UNUSED_PARAM(state);
@@ -206,7 +263,43 @@
 }
 
 
+bool setJSTestGlobalObjectPublicAndPrivateAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
+{
+    JSValue value = JSValue::decode(encodedValue);
+    UNUSED_PARAM(thisValue);
+    JSTestGlobalObject* castedThis = jsDynamicCast<JSTestGlobalObject*>(JSValue::decode(thisValue));
+    if (UNLIKELY(!castedThis)) {
+        return throwSetterTypeError(*state, "TestGlobalObject", "publicAndPrivateAttribute");
+    }
+    auto& impl = castedThis->wrapped();
+    auto nativeValue = value.toWTFString(state);
+    if (UNLIKELY(state->hadException()))
+        return false;
+    impl.setPublicAndPrivateAttribute(WTFMove(nativeValue));
+    return true;
+}
+
+
 #if ENABLE(TEST_FEATURE)
+bool setJSTestGlobalObjectPublicAndPrivateConditionalAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
+{
+    JSValue value = JSValue::decode(encodedValue);
+    UNUSED_PARAM(thisValue);
+    JSTestGlobalObject* castedThis = jsDynamicCast<JSTestGlobalObject*>(JSValue::decode(thisValue));
+    if (UNLIKELY(!castedThis)) {
+        return throwSetterTypeError(*state, "TestGlobalObject", "publicAndPrivateConditionalAttribute");
+    }
+    auto& impl = castedThis->wrapped();
+    auto nativeValue = value.toWTFString(state);
+    if (UNLIKELY(state->hadException()))
+        return false;
+    impl.setPublicAndPrivateConditionalAttribute(WTFMove(nativeValue));
+    return true;
+}
+
+#endif
+
+#if ENABLE(TEST_FEATURE)
 bool setJSTestGlobalObjectEnabledAtRuntimeAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
 {
     JSValue value = JSValue::decode(encodedValue);

Modified: trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestGlobalObject.h (202550 => 202551)


--- trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestGlobalObject.h	2016-06-28 07:03:16 UTC (rev 202550)
+++ trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestGlobalObject.h	2016-06-28 07:04:55 UTC (rev 202551)
@@ -31,6 +31,8 @@
 WEBKIT_CLASS_AVAILABLE_MAC(9876_5)
 WEBCORE_EXPORT @interface DOMTestGlobalObject : DOMObject
 @property (copy) NSString *regularAttribute;
+@property (copy) NSString *publicAndPrivateAttribute;
+@property (copy) NSString *publicAndPrivateConditionalAttribute;
 @property (copy) NSString *enabledAtRuntimeAttribute;
 
 - (void)regularOperation:(NSString *)testParam;

Modified: trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestGlobalObject.mm (202550 => 202551)


--- trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestGlobalObject.mm	2016-06-28 07:03:16 UTC (rev 202550)
+++ trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestGlobalObject.mm	2016-06-28 07:04:55 UTC (rev 202551)
@@ -66,7 +66,33 @@
     IMPL->setRegularAttribute(newRegularAttribute);
 }
 
+- (NSString *)publicAndPrivateAttribute
+{
+    WebCore::JSMainThreadNullState state;
+    return IMPL->publicAndPrivateAttribute();
+}
+
+- (void)setPublicAndPrivateAttribute:(NSString *)newPublicAndPrivateAttribute
+{
+    WebCore::JSMainThreadNullState state;
+    IMPL->setPublicAndPrivateAttribute(newPublicAndPrivateAttribute);
+}
+
 #if ENABLE(TEST_FEATURE)
+- (NSString *)publicAndPrivateConditionalAttribute
+{
+    WebCore::JSMainThreadNullState state;
+    return IMPL->publicAndPrivateConditionalAttribute();
+}
+
+- (void)setPublicAndPrivateConditionalAttribute:(NSString *)newPublicAndPrivateConditionalAttribute
+{
+    WebCore::JSMainThreadNullState state;
+    IMPL->setPublicAndPrivateConditionalAttribute(newPublicAndPrivateConditionalAttribute);
+}
+#endif
+
+#if ENABLE(TEST_FEATURE)
 - (NSString *)enabledAtRuntimeAttribute
 {
     WebCore::JSMainThreadNullState state;

Modified: trunk/Source/WebCore/bindings/scripts/test/TestGlobalObject.idl (202550 => 202551)


--- trunk/Source/WebCore/bindings/scripts/test/TestGlobalObject.idl	2016-06-28 07:03:16 UTC (rev 202550)
+++ trunk/Source/WebCore/bindings/scripts/test/TestGlobalObject.idl	2016-06-28 07:04:55 UTC (rev 202551)
@@ -26,6 +26,8 @@
 // This interface is recognized as a global object by the bindings generator.
 interface TestGlobalObject {
     attribute DOMString regularAttribute;
+    [PrivateIdentifier, PublicIdentifier] attribute DOMString publicAndPrivateAttribute;
+    [Conditional=TEST_FEATURE, PrivateIdentifier, PublicIdentifier] attribute DOMString publicAndPrivateConditionalAttribute;
     [Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] attribute DOMString enabledAtRuntimeAttribute;
     void regularOperation(DOMString testParam);
     [Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] void enabledAtRuntimeOperation(DOMString testParam);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to