Changeset 166070 in webkit


Ignore:
Timestamp:
Mar 21, 2014 10:29:03 AM (10 years ago)
Author:
msaboff@apple.com
Message:

Change CodeGeneratorJS.pm special cases for "DOMWindow" to be general purpose
https://bugs.webkit.org/show_bug.cgi?id=130553

Reviewed by Geoffrey Garen.

Eliminated 'if ($interfaceName eq "DOMWindow") {' sections in CodeGeneratorJS where
it was used to do DOMWindow specific casting to a JSObject, either a JSDOMWindow* or
a JSDOMWindowShell*. Instead the code generator will use the existing
JSDOMWindow* toJSDOMWindow(JSValue value) function based on a newly added attribute
"CustomProxyToJSObject". That attribute will emit a call to the function
${className}* to${className}(JSValue).

This is being done to clean up the code generator and for a subsequent patch that
will use a similar custom to{className} function for workers,
JSDedicatedWorkerGlobalScope* toJSDedicatedWorkerGlobalScope(JSValue).

Changes covered by existing tests.

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateImplementation):

  • bindings/scripts/IDLAttributes.txt:
  • page/DOMWindow.idl:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r166069 r166070  
     12014-03-21  Michael Saboff  <msaboff@apple.com>
     2
     3        Change CodeGeneratorJS.pm special cases for "DOMWindow" to be general purpose
     4        https://bugs.webkit.org/show_bug.cgi?id=130553
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Eliminated 'if ($interfaceName eq "DOMWindow") {' sections in CodeGeneratorJS where
     9        it was used to do DOMWindow specific casting to a JSObject, either a JSDOMWindow* or
     10        a JSDOMWindowShell*.  Instead the code generator will use the existing
     11        JSDOMWindow* toJSDOMWindow(JSValue value) function based on a newly added attribute
     12        "CustomProxyToJSObject".  That attribute will emit a call to the function
     13        ${className}* to${className}(JSValue).
     14
     15        This is being done to clean up the code generator and for a subsequent patch that
     16        will use a similar custom to{className} function for workers,
     17        JSDedicatedWorkerGlobalScope* toJSDedicatedWorkerGlobalScope(JSValue).
     18
     19        Changes covered by existing tests.
     20
     21        * bindings/scripts/CodeGeneratorJS.pm:
     22        (GenerateImplementation):
     23        * bindings/scripts/IDLAttributes.txt:
     24        * page/DOMWindow.idl:
     25
    1262014-03-21  Krzysztof Czech  <k.czech@samsung.com>
    227
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r165914 r166070  
    21282128
    21292129            if (!$attribute->isStatic || $attribute->signature->type =~ /Constructor$/) {
    2130                 if ($interfaceName eq "DOMWindow") {
    2131                     push(@implContent, "    ${className}* castedThis = jsDynamicCast<$className*>(JSValue::decode(thisValue));\n");
    2132                     push(@implContent, "    if (UNLIKELY(!castedThis)) {\n");
    2133                     push(@implContent, "        if (JSDOMWindowShell* shell = jsDynamicCast<JSDOMWindowShell*>(JSValue::decode(thisValue)))\n");
    2134                     push(@implContent, "            castedThis = shell->window();\n");
    2135                     push(@implContent, "    }\n");
     2130                if ($interface->extendedAttributes->{"CustomProxyToJSObject"}) {
     2131                    push(@implContent, "    ${className}* castedThis = to${className}(JSValue::decode(thisValue));\n");
    21362132                    push(@implContent, "    UNUSED_PARAM(slotBase);\n");
    21372133                } else {
     
    23512347            push(@implContent, "    UNUSED_PARAM(baseValue);\n");
    23522348            push(@implContent, "    UNUSED_PARAM(thisValue);\n");
    2353             if ($interfaceName eq "DOMWindow") {
    2354                 push(@implContent, "    ${className}* domObject = jsDynamicCast<$className*>(JSValue::decode(thisValue));\n");
    2355                 push(@implContent, "    if (!domObject) {\n");
    2356                 push(@implContent, "        if (JSDOMWindowShell* shell = jsDynamicCast<JSDOMWindowShell*>(JSValue::decode(thisValue)))\n");
    2357                 push(@implContent, "            domObject = shell->window();\n");
    2358                 push(@implContent, "    }\n");
     2349            if ($interface->extendedAttributes->{"CustomProxyToJSObject"}) {
     2350                push(@implContent, "    ${className}* domObject = to${className}(JSValue::decode(thisValue));\n");
    23592351            } else {
    23602352                push(@implContent, "    ${className}* domObject = jsDynamicCast<${className}*>(JSValue::decode(thisValue));\n") if ConstructorShouldBeOnInstance($interface);
     
    23802372            push(@implContent, "{\n");
    23812373            push(@implContent, "    JSValue value = JSValue::decode(encodedValue);");
    2382             push(@implContent, "    ${className}* castedThis = jsDynamicCast<${className}*>(JSValue::decode(thisValue));\n");
    2383             if ($interfaceName eq "DOMWindow") {
    2384                 push(@implContent, "    if (UNLIKELY(!castedThis)) {\n");
    2385                 push(@implContent, "        if (JSDOMWindowShell* shell = jsDynamicCast<JSDOMWindowShell*>(JSValue::decode(thisValue)))\n");
    2386                 push(@implContent, "            castedThis = shell->window();\n");
    2387                 push(@implContent, "    }\n");
     2374            if ($interface->extendedAttributes->{"CustomProxyToJSObject"}) {
     2375                push(@implContent, "    ${className}* castedThis = to${className}(JSValue::decode(thisValue));\n");
     2376            } else {
     2377                push(@implContent, "    ${className}* castedThis = jsDynamicCast<${className}*>(JSValue::decode(thisValue));\n");
    23882378            }
    23892379            push(@implContent, "    if (UNLIKELY(!castedThis)) {\n");
     
    24892479                push(@implContent, "    UNUSED_PARAM(exec);\n");
    24902480                if (!$attribute->isStatic) {
    2491                     push(@implContent, "    ${className}* castedThis = jsDynamicCast<${className}*>(JSValue::decode(thisValue));\n");
    2492                     if ($interfaceName eq "DOMWindow") {
    2493                         push(@implContent, "    if (UNLIKELY(!castedThis)) {\n");
    2494                         push(@implContent, "        if (JSDOMWindowShell* shell = jsDynamicCast<JSDOMWindowShell*>(JSValue::decode(thisValue)))\n");
    2495                         push(@implContent, "            castedThis = shell->window();\n");
    2496                         push(@implContent, "    }\n");
     2481                    if ($interface->extendedAttributes->{"CustomProxyToJSObject"}) {
     2482                        push(@implContent, "    ${className}* castedThis = to${className}(JSValue::decode(thisValue));\n");
     2483                    } else {
     2484                        push(@implContent, "    ${className}* castedThis = jsDynamicCast<${className}*>(JSValue::decode(thisValue));\n");
    24972485                    }
    24982486                    push(@implContent, "    if (UNLIKELY(!castedThis)) {\n");
     
    27192707                }
    27202708            } else {
    2721                 if ($interfaceName eq "DOMWindow") {
    2722                     push(@implContent, "    $className* castedThis = toJSDOMWindow(exec->hostThisValue().toThis(exec, NotStrictMode));\n");
     2709                if ($interface->extendedAttributes->{"CustomProxyToJSObject"}) {
     2710                    push(@implContent, "    $className* castedThis = to${className}(exec->hostThisValue().toThis(exec, NotStrictMode));\n");
    27232711                    push(@implContent, "    if (UNLIKELY(!castedThis))\n");
    27242712                    push(@implContent, "        return throwVMTypeError(exec);\n");
  • trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt

    r165521 r166070  
    4444CustomNamedGetter
    4545CustomNamedSetter
     46CustomProxyToJSObject
    4647CustomPutFunction
    4748CustomReturn
  • trunk/Source/WebCore/page/DOMWindow.idl

    r165676 r166070  
    3131    CustomGetOwnPropertySlot,
    3232    CustomEnumerateProperty,
     33    CustomProxyToJSObject,
    3334    JSCustomMarkFunction,
    3435    JSCustomToNativeObject,
Note: See TracChangeset for help on using the changeset viewer.