Changeset 122912 in webkit


Ignore:
Timestamp:
Jul 17, 2012 6:16:14 PM (12 years ago)
Author:
jonlee@apple.com
Message:

Teach CodeGenerator to support for static, readonly, attributes
https://bugs.webkit.org/show_bug.cgi?id=88920
<rdar://problem/11650330>

Reviewed by Oliver Hunt.

Update the parser to be able to accept the static keyword for attribute. We will treat static attributes
like custom static functions. They call the implementing class directly, and pass in the ExecState as a script context.

  • bindings/scripts/CodeGeneratorJS.pm:

(GetAttributeGetterName): Factor out the construction of the attribute getter function name.
(GetAttributeSetterName): Factor out the construction of the attribute setter function name.
(GenerateHeader): Determine that a class has read-write properties only if there is a read-write attribute that
is not static.
(GenerateAttributesHashTable): Skip static attributes in the object hash table. They will be added to the constructor
hash table.
(GenerateImplementation): Look for static attributes to add to the constructor hash table. Make a call to the static
function in the class.

  • bindings/scripts/IDLParser.pm:

(ParseInterface): Update the processing because of the regex change.

  • bindings/scripts/IDLStructure.pm: Update the attribute regex.
  • bindings/scripts/test/JS/JSTestObj.cpp: Update test results.
  • bindings/scripts/test/JS/JSTestObj.h: Update test results.
  • bindings/scripts/test/TestObj.idl: Add test cases.
Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r122911 r122912  
     12012-07-17  Jon Lee  <jonlee@apple.com>
     2
     3        Teach CodeGenerator to support for static, readonly, attributes
     4        https://bugs.webkit.org/show_bug.cgi?id=88920
     5        <rdar://problem/11650330>
     6
     7        Reviewed by Oliver Hunt.
     8
     9        Update the parser to be able to accept the static keyword for attribute. We will treat static attributes
     10        like custom static functions. They call the implementing class directly, and pass in the ExecState as a script context.
     11
     12        * bindings/scripts/CodeGeneratorJS.pm:
     13        (GetAttributeGetterName): Factor out the construction of the attribute getter function name.
     14        (GetAttributeSetterName): Factor out the construction of the attribute setter function name.
     15        (GenerateHeader): Determine that a class has read-write properties only if there is a read-write attribute that
     16        is not static.
     17        (GenerateAttributesHashTable): Skip static attributes in the object hash table. They will be added to the constructor
     18        hash table.
     19        (GenerateImplementation): Look for static attributes to add to the constructor hash table. Make a call to the static
     20        function in the class.
     21        * bindings/scripts/IDLParser.pm:
     22        (ParseInterface): Update the processing because of the regex change.
     23        * bindings/scripts/IDLStructure.pm: Update the attribute regex.
     24        * bindings/scripts/test/JS/JSTestObj.cpp: Update test results.
     25        * bindings/scripts/test/JS/JSTestObj.h: Update test results.
     26        * bindings/scripts/test/TestObj.idl: Add test cases.
     27
    1282012-07-17  Kenichi Ishibashi  <bashi@chromium.org>
    229
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r122561 r122912  
    635635}
    636636
     637sub GetAttributeGetterName
     638{
     639    my ($interfaceName, $className, $attribute) = @_;
     640    if ($attribute->isStatic) {
     641        return $codeGenerator->WK_lcfirst($className) . "Constructor" . $codeGenerator->WK_ucfirst($attribute->signature->name);
     642    }
     643    return "js" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : "");
     644}
     645
     646sub GetAttributeSetterName
     647{
     648    my ($interfaceName, $className, $attribute) = @_;
     649    if ($attribute->isStatic) {
     650        return "set" . $codeGenerator->WK_ucfirst($className) . "Constructor" . $codeGenerator->WK_ucfirst($attribute->signature->name);
     651    }
     652    return "setJS" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : "");
     653}
     654
    637655sub GetFunctionName
    638656{
     
    786804    my $hasReadWriteProperties = 0;
    787805    foreach (@{$dataNode->attributes}) {
    788         if ($_->type !~ /^readonly\ attribute$/) {
     806        if ($_->type !~ /^readonly\ attribute$/ && !$_->isStatic) {
    789807            $hasReadWriteProperties = 1;
    790808        }
     
    11181136            my $conditionalString = $codeGenerator->GenerateConditionalString($attribute->signature);
    11191137            push(@headerContent, "#if ${conditionalString}\n") if $conditionalString;
    1120             my $getter = "js" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : "");
     1138            my $getter = GetAttributeGetterName($interfaceName, $className, $attribute);
    11211139            push(@headerContent, "JSC::JSValue ${getter}(JSC::ExecState*, JSC::JSValue, JSC::PropertyName);\n");
    11221140            unless ($attribute->type =~ /readonly/) {
    1123                 my $setter = "setJS" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : "");
     1141                my $setter = GetAttributeSetterName($interfaceName, $className, $attribute);
    11241142                push(@headerContent, "void ${setter}(JSC::ExecState*, JSC::JSObject*, JSC::JSValue);\n");
    11251143            }
     
    11871205
    11881206    foreach my $attribute (@{$dataNode->attributes}) {
     1207        next if ($attribute->isStatic);
    11891208        my $name = $attribute->signature->name;
    11901209        push(@hashKeys, $name);
     
    11971216        push(@hashSpecials, $special);
    11981217
    1199         my $getter = "js" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : "");
     1218        my $getter = GetAttributeGetterName($interfaceName, $className, $attribute);
    12001219        push(@hashValue1, $getter);
    12011220
     
    12031222            push(@hashValue2, "0");
    12041223        } else {
    1205             my $setter = "setJS" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : "");
     1224            my $setter = GetAttributeSetterName($interfaceName, $className, $attribute);
    12061225            push(@hashValue2, $setter);
    12071226        }
     
    14091428            }
    14101429            my $conditional = $constant->extendedAttributes->{"Conditional"};
     1430            if ($conditional) {
     1431                $conditionals{$name} = $conditional;
     1432            }
     1433        }
     1434
     1435        foreach my $attribute (@{$dataNode->attributes}) {
     1436            next unless ($attribute->isStatic);
     1437            my $name = $attribute->signature->name;
     1438            push(@hashKeys, $name);
     1439
     1440            my @specials = ();
     1441            push(@specials, "DontDelete") unless $attribute->signature->extendedAttributes->{"Deletable"};
     1442            push(@specials, "ReadOnly") if $attribute->type =~ /readonly/;
     1443            my $special = (@specials > 0) ? join(" | ", @specials) : "0";
     1444            push(@hashSpecials, $special);
     1445
     1446            my $getter = GetAttributeGetterName($interfaceName, $className, $attribute);
     1447            push(@hashValue1, $getter);
     1448
     1449            if ($attribute->type =~ /readonly/) {
     1450                push(@hashValue2, "0");
     1451            } else {
     1452                my $setter = GetAttributeSetterName($interfaceName, $className, $attribute);
     1453                push(@hashValue2, $setter);
     1454            }
     1455
     1456            my $conditional = $attribute->signature->extendedAttributes->{"Conditional"};
    14111457            if ($conditional) {
    14121458                $conditionals{$name} = $conditional;
     
    17151761                my $type = $codeGenerator->StripModule($attribute->signature->type);               
    17161762                $codeGenerator->AssertNotSequenceType($type);
    1717                 my $getFunctionName = "js" . $interfaceName .  $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : "");
     1763                my $getFunctionName = GetAttributeGetterName($interfaceName, $className, $attribute);
    17181764                my $implGetterFunctionName = $codeGenerator->WK_lcfirst($name);
    17191765
     
    17211767                push(@implContent, "#if ${attributeConditionalString}\n") if $attributeConditionalString;
    17221768
    1723                 push(@implContent, "JSValue ${getFunctionName}(ExecState* exec, JSValue slotBase, PropertyName)\n");
     1769                push(@implContent, "JSValue ${getFunctionName}(ExecState* exec, JSValue");
     1770                push(@implContent, " slotBase") if !$attribute->isStatic;
     1771                push(@implContent, ", PropertyName)\n");
    17241772                push(@implContent, "{\n");
    1725                 push(@implContent, "    ${className}* castedThis = jsCast<$className*>(asObject(slotBase));\n");
    1726 
    1727                 if ($attribute->signature->extendedAttributes->{"CachedAttribute"}) {
    1728                     $needsMarkChildren = 1;
    1729                 }
    1730 
    1731                 if ($dataNode->extendedAttributes->{"CheckSecurity"} &&
    1732                         !$attribute->signature->extendedAttributes->{"DoNotCheckSecurity"} &&
    1733                         !$attribute->signature->extendedAttributes->{"DoNotCheckSecurityOnGetter"}) {
    1734                     push(@implContent, "    if (!castedThis->allowsAccessFrom(exec))\n");
     1773
     1774                if ($attribute->isStatic) {
     1775                    push(@implContent, "    ScriptExecutionContext* scriptContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();\n");
     1776                    push(@implContent, "    if (!scriptContext)\n");
    17351777                    push(@implContent, "        return jsUndefined();\n");
    1736                 }
    1737 
    1738                 if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCustom"} || $attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCustomGetter"}) {
    1739                     push(@implContent, "    return castedThis->$implGetterFunctionName(exec);\n");
    1740                 } elsif ($attribute->signature->extendedAttributes->{"CheckSecurityForNode"}) {
    1741                     $implIncludes{"JSDOMBinding.h"} = 1;
    1742                     push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(castedThis->impl());\n");
    1743                     push(@implContent, "    return shouldAllowAccessToNode(exec, impl->" . $attribute->signature->name . "()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl->$implGetterFunctionName()", "castedThis") . " : jsNull();\n");
    1744                 } elsif ($type eq "EventListener") {
    1745                     $implIncludes{"EventListener.h"} = 1;
    1746                     push(@implContent, "    UNUSED_PARAM(exec);\n");
    1747                     push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(castedThis->impl());\n");
    1748                     push(@implContent, "    if (EventListener* listener = impl->$implGetterFunctionName()) {\n");
    1749                     push(@implContent, "        if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {\n");
    1750                     if ($implClassName eq "Document" || $implClassName eq "WorkerContext" || $implClassName eq "SharedWorkerContext" || $implClassName eq "DedicatedWorkerContext") {
    1751                         push(@implContent, "            if (JSObject* jsFunction = jsListener->jsFunction(impl))\n");
     1778                    push(@implContent, "    JSC::JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "${implClassName}::$implGetterFunctionName(scriptContext)", "") . ";\n");
     1779                    push(@implContent, "    return result;\n");
     1780                } else {
     1781                    push(@implContent, "    ${className}* castedThis = jsCast<$className*>(asObject(slotBase));\n");
     1782
     1783                    if ($attribute->signature->extendedAttributes->{"CachedAttribute"}) {
     1784                        $needsMarkChildren = 1;
     1785                    }
     1786
     1787                    if ($dataNode->extendedAttributes->{"CheckSecurity"} &&
     1788                            !$attribute->signature->extendedAttributes->{"DoNotCheckSecurity"} &&
     1789                            !$attribute->signature->extendedAttributes->{"DoNotCheckSecurityOnGetter"}) {
     1790                        push(@implContent, "    if (!castedThis->allowsAccessFrom(exec))\n");
     1791                        push(@implContent, "        return jsUndefined();\n");
     1792                    }
     1793
     1794                    if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCustom"} || $attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCustomGetter"}) {
     1795                        push(@implContent, "    return castedThis->$implGetterFunctionName(exec);\n");
     1796                    } elsif ($attribute->signature->extendedAttributes->{"CheckSecurityForNode"}) {
     1797                        $implIncludes{"JSDOMBinding.h"} = 1;
     1798                        push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(castedThis->impl());\n");
     1799                        push(@implContent, "    return shouldAllowAccessToNode(exec, impl->" . $attribute->signature->name . "()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl->$implGetterFunctionName()", "castedThis") . " : jsNull();\n");
     1800                    } elsif ($type eq "EventListener") {
     1801                        $implIncludes{"EventListener.h"} = 1;
     1802                        push(@implContent, "    UNUSED_PARAM(exec);\n");
     1803                        push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(castedThis->impl());\n");
     1804                        push(@implContent, "    if (EventListener* listener = impl->$implGetterFunctionName()) {\n");
     1805                        push(@implContent, "        if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {\n");
     1806                        if ($implClassName eq "Document" || $implClassName eq "WorkerContext" || $implClassName eq "SharedWorkerContext" || $implClassName eq "DedicatedWorkerContext") {
     1807                            push(@implContent, "            if (JSObject* jsFunction = jsListener->jsFunction(impl))\n");
     1808                        } else {
     1809                            push(@implContent, "            if (JSObject* jsFunction = jsListener->jsFunction(impl->scriptExecutionContext()))\n");
     1810                        }
     1811                        push(@implContent, "                return jsFunction;\n");
     1812                        push(@implContent, "        }\n");
     1813                        push(@implContent, "    }\n");
     1814                        push(@implContent, "    return jsNull();\n");
     1815                    } elsif ($attribute->signature->type =~ /Constructor$/) {
     1816                        my $constructorType = $codeGenerator->StripModule($attribute->signature->type);
     1817                        $constructorType =~ s/Constructor$//;
     1818                        # Constructor attribute is only used by DOMWindow.idl, so it's correct to pass castedThis as the global object
     1819                        # Once JSDOMWrappers have a back-pointer to the globalObject we can pass castedThis->globalObject()
     1820                        push(@implContent, "    return JS" . $constructorType . "::getConstructor(exec, castedThis);\n");
     1821                    } elsif (!@{$attribute->getterExceptions}) {
     1822                        push(@implContent, "    UNUSED_PARAM(exec);\n") if !$attribute->signature->extendedAttributes->{"CallWith"};
     1823
     1824                        my $cacheIndex = 0;
     1825                        if ($attribute->signature->extendedAttributes->{"CachedAttribute"}) {
     1826                            $cacheIndex = $currentCachedAttribute;
     1827                            $currentCachedAttribute++;
     1828                            push(@implContent, "    if (JSValue cachedValue = castedThis->m_" . $attribute->signature->name . ".get())\n");
     1829                            push(@implContent, "        return cachedValue;\n");
     1830                        }
     1831
     1832                        my @callWithArgs = GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContent, "jsUndefined()");
     1833
     1834                        if ($svgListPropertyType) {
     1835                            push(@implContent, "    JSValue result =  " . NativeToJSValue($attribute->signature, 0, $implClassName, "castedThis->impl()->$implGetterFunctionName(" . (join ", ", @callWithArgs) . ")", "castedThis") . ";\n");
     1836                        } elsif ($svgPropertyOrListPropertyType) {
     1837                            push(@implContent, "    $svgPropertyOrListPropertyType& impl = castedThis->impl()->propertyReference();\n");
     1838                            if ($svgPropertyOrListPropertyType eq "float") { # Special case for JSSVGNumber
     1839                                push(@implContent, "    JSValue result =  " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl", "castedThis") . ";\n");
     1840                            } else {
     1841                                push(@implContent, "    JSValue result =  " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl.$implGetterFunctionName(" . (join ", ", @callWithArgs) . ")", "castedThis") . ";\n");
     1842
     1843                            }
     1844                        } else {
     1845                            my ($functionName, @arguments) = $codeGenerator->GetterExpression(\%implIncludes, $interfaceName, $attribute);
     1846                            if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
     1847                                my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"};
     1848                                $implIncludes{"${implementedBy}.h"} = 1;
     1849                                $functionName = "${implementedBy}::${functionName}";
     1850                                unshift(@arguments, "impl");
     1851                            } else {
     1852                                $functionName = "impl->${functionName}";
     1853                            }
     1854
     1855                            unshift(@arguments, @callWithArgs);
     1856
     1857                            my $jsType = NativeToJSValue($attribute->signature, 0, $implClassName, "${functionName}(" . join(", ", @arguments) . ")", "castedThis");
     1858                            push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(castedThis->impl());\n");
     1859                            if ($codeGenerator->IsSVGAnimatedType($type)) {
     1860                                push(@implContent, "    RefPtr<$type> obj = $jsType;\n");
     1861                                push(@implContent, "    JSValue result =  toJS(exec, castedThis->globalObject(), obj.get());\n");
     1862                            } else {
     1863                                push(@implContent, "    JSValue result = $jsType;\n");
     1864                            }
     1865                        }
     1866
     1867                        push(@implContent, "    castedThis->m_" . $attribute->signature->name . ".set(exec->globalData(), castedThis, result);\n") if ($attribute->signature->extendedAttributes->{"CachedAttribute"});
     1868                        push(@implContent, "    return result;\n");
     1869
    17521870                    } else {
    1753                         push(@implContent, "            if (JSObject* jsFunction = jsListener->jsFunction(impl->scriptExecutionContext()))\n");
     1871                        my @arguments = ("ec");
     1872                        push(@implContent, "    ExceptionCode ec = 0;\n");
     1873
     1874                        unshift(@arguments, GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContent, "jsUndefined()"));
     1875
     1876                        if ($svgPropertyOrListPropertyType) {
     1877                            push(@implContent, "    $svgPropertyOrListPropertyType impl(*castedThis->impl());\n");
     1878                            push(@implContent, "    JSC::JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl.$implGetterFunctionName(" . join(", ", @arguments) . ")", "castedThis") . ";\n");
     1879                        } else {
     1880                            push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(castedThis->impl());\n");
     1881                            push(@implContent, "    JSC::JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl->$implGetterFunctionName(" . join(", ", @arguments) . ")", "castedThis") . ";\n");
     1882                        }
     1883
     1884                        push(@implContent, "    setDOMException(exec, ec);\n");
     1885                        push(@implContent, "    return result;\n");
    17541886                    }
    1755                     push(@implContent, "                return jsFunction;\n");
    1756                     push(@implContent, "        }\n");
    1757                     push(@implContent, "    }\n");
    1758                     push(@implContent, "    return jsNull();\n");
    1759                 } elsif ($attribute->signature->type =~ /Constructor$/) {
    1760                     my $constructorType = $codeGenerator->StripModule($attribute->signature->type);
    1761                     $constructorType =~ s/Constructor$//;
    1762                     # Constructor attribute is only used by DOMWindow.idl, so it's correct to pass castedThis as the global object
    1763                     # Once JSDOMWrappers have a back-pointer to the globalObject we can pass castedThis->globalObject()
    1764                     push(@implContent, "    return JS" . $constructorType . "::getConstructor(exec, castedThis);\n");
    1765                 } elsif (!@{$attribute->getterExceptions}) {
    1766                     push(@implContent, "    UNUSED_PARAM(exec);\n") if !$attribute->signature->extendedAttributes->{"CallWith"};
    1767 
    1768                     my $cacheIndex = 0;
    1769                     if ($attribute->signature->extendedAttributes->{"CachedAttribute"}) {
    1770                         $cacheIndex = $currentCachedAttribute;
    1771                         $currentCachedAttribute++;
    1772                         push(@implContent, "    if (JSValue cachedValue = castedThis->m_" . $attribute->signature->name . ".get())\n");
    1773                         push(@implContent, "        return cachedValue;\n");
    1774                     }
    1775 
    1776                     my @callWithArgs = GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContent, "jsUndefined()");
    1777 
    1778                     if ($svgListPropertyType) {
    1779                         push(@implContent, "    JSValue result =  " . NativeToJSValue($attribute->signature, 0, $implClassName, "castedThis->impl()->$implGetterFunctionName(" . (join ", ", @callWithArgs) . ")", "castedThis") . ";\n");
    1780                     } elsif ($svgPropertyOrListPropertyType) {
    1781                         push(@implContent, "    $svgPropertyOrListPropertyType& impl = castedThis->impl()->propertyReference();\n");
    1782                         if ($svgPropertyOrListPropertyType eq "float") { # Special case for JSSVGNumber
    1783                             push(@implContent, "    JSValue result =  " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl", "castedThis") . ";\n");
    1784                         } else {
    1785                             push(@implContent, "    JSValue result =  " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl.$implGetterFunctionName(" . (join ", ", @callWithArgs) . ")", "castedThis") . ";\n");
    1786 
    1787                         }
    1788                     } else {
    1789                         my ($functionName, @arguments) = $codeGenerator->GetterExpression(\%implIncludes, $interfaceName, $attribute);
    1790                         if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
    1791                             my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"};
    1792                             $implIncludes{"${implementedBy}.h"} = 1;
    1793                             $functionName = "${implementedBy}::${functionName}";
    1794                             unshift(@arguments, "impl");
    1795                         } else {
    1796                             $functionName = "impl->${functionName}";
    1797                         }
    1798 
    1799                         unshift(@arguments, @callWithArgs);
    1800 
    1801                         my $jsType = NativeToJSValue($attribute->signature, 0, $implClassName, "${functionName}(" . join(", ", @arguments) . ")", "castedThis");
    1802                         push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(castedThis->impl());\n");
    1803                         if ($codeGenerator->IsSVGAnimatedType($type)) {
    1804                             push(@implContent, "    RefPtr<$type> obj = $jsType;\n");
    1805                             push(@implContent, "    JSValue result =  toJS(exec, castedThis->globalObject(), obj.get());\n");
    1806                         } else {
    1807                             push(@implContent, "    JSValue result = $jsType;\n");
    1808                         }
    1809                     }
    1810 
    1811                     push(@implContent, "    castedThis->m_" . $attribute->signature->name . ".set(exec->globalData(), castedThis, result);\n") if ($attribute->signature->extendedAttributes->{"CachedAttribute"});
    1812                     push(@implContent, "    return result;\n");
    1813 
    1814                 } else {
    1815                     my @arguments = ("ec");
    1816                     push(@implContent, "    ExceptionCode ec = 0;\n");
    1817 
    1818                     unshift(@arguments, GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContent, "jsUndefined()"));
    1819 
    1820                     if ($svgPropertyOrListPropertyType) {
    1821                         push(@implContent, "    $svgPropertyOrListPropertyType impl(*castedThis->impl());\n");
    1822                         push(@implContent, "    JSC::JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl.$implGetterFunctionName(" . join(", ", @arguments) . ")", "castedThis") . ";\n");
    1823                     } else {
    1824                         push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(castedThis->impl());\n");
    1825                         push(@implContent, "    JSC::JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl->$implGetterFunctionName(" . join(", ", @arguments) . ")", "castedThis") . ";\n");
    1826                     }
    1827 
    1828                     push(@implContent, "    setDOMException(exec, ec);\n");
    1829                     push(@implContent, "    return result;\n");
    18301887                }
    18311888
     
    18571914        my $hasReadWriteProperties = 0;
    18581915        foreach my $attribute (@{$dataNode->attributes}) {
    1859             $hasReadWriteProperties = 1 if $attribute->type !~ /^readonly/;
     1916            $hasReadWriteProperties = 1 if $attribute->type !~ /^readonly/ && !$attribute->isStatic;
    18601917        }
    18611918
     
    19051962                        my $name = $attribute->signature->name;
    19061963                        my $type = $codeGenerator->StripModule($attribute->signature->type);
    1907                         my $putFunctionName = "setJS" . $interfaceName .  $codeGenerator->WK_ucfirst($name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : "");
     1964                        my $putFunctionName = GetAttributeSetterName($interfaceName, $className, $attribute);
    19081965                        my $implSetterFunctionName = $codeGenerator->WK_ucfirst($name);
    19091966
     
    19111968                        push(@implContent, "#if ${attributeConditionalString}\n") if $attributeConditionalString;
    19121969
    1913                         push(@implContent, "void ${putFunctionName}(ExecState* exec, JSObject* thisObject, JSValue value)\n");
     1970                        push(@implContent, "void ${putFunctionName}(ExecState* exec, JSObject*");
     1971                        push(@implContent, " thisObject") if !$attribute->isStatic;
     1972                        push(@implContent, ", JSValue value)\n");
    19141973                        push(@implContent, "{\n");
    1915                         push(@implContent, "    UNUSED_PARAM(exec);\n");
    1916 
    1917                         if ($dataNode->extendedAttributes->{"CheckSecurity"} && !$attribute->signature->extendedAttributes->{"DoNotCheckSecurity"}) {
    1918                             if ($interfaceName eq "DOMWindow") {
    1919                                 push(@implContent, "    if (!jsCast<$className*>(thisObject)->allowsAccessFrom(exec))\n");
     1974
     1975                        if ($attribute->isStatic) {
     1976                            push(@implContent, "    ScriptExecutionContext* scriptContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();\n");
     1977                            push(@implContent, "    if (!scriptContext)\n");
     1978                            push(@implContent, "        return;\n");
     1979                            my $nativeValue = JSValueToNative($attribute->signature, "value");
     1980                            push(@implContent, "    ${implClassName}::set$implSetterFunctionName(scriptContext, ${nativeValue});\n");
     1981                        } else {
     1982                            push(@implContent, "    UNUSED_PARAM(exec);\n");
     1983
     1984                            if ($dataNode->extendedAttributes->{"CheckSecurity"} && !$attribute->signature->extendedAttributes->{"DoNotCheckSecurity"}) {
     1985                                if ($interfaceName eq "DOMWindow") {
     1986                                    push(@implContent, "    if (!jsCast<$className*>(thisObject)->allowsAccessFrom(exec))\n");
     1987                                } else {
     1988                                    push(@implContent, "    if (!shouldAllowAccessToFrame(exec, jsCast<$className*>(thisObject)->impl()->frame()))\n");
     1989                                }
     1990                                push(@implContent, "        return;\n");
     1991                            }
     1992
     1993                            if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCustom"} || $attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCustomSetter"}) {
     1994                                push(@implContent, "    jsCast<$className*>(thisObject)->set$implSetterFunctionName(exec, value);\n");
     1995                            } elsif ($type eq "EventListener") {
     1996                                $implIncludes{"JSEventListener.h"} = 1;
     1997                                push(@implContent, "    UNUSED_PARAM(exec);\n");
     1998                                push(@implContent, "    ${className}* castedThis = jsCast<${className}*>(thisObject);\n");
     1999                                my $windowEventListener = $attribute->signature->extendedAttributes->{"JSWindowEventListener"};
     2000                                if ($windowEventListener) {
     2001                                    push(@implContent, "    JSDOMGlobalObject* globalObject = castedThis->globalObject();\n");
     2002                                }
     2003                                push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(castedThis->impl());\n");
     2004                                if ((($interfaceName eq "DOMWindow") or ($interfaceName eq "WorkerContext")) and $name eq "onerror") {
     2005                                    $implIncludes{"JSErrorHandler.h"} = 1;
     2006                                    push(@implContent, "    impl->set$implSetterFunctionName(createJSErrorHandler(exec, value, thisObject));\n");
     2007                                } else {
     2008                                    push(@implContent, GenerateAttributeEventListenerCall($className, $implSetterFunctionName, $windowEventListener));
     2009                                }
     2010                            } elsif ($attribute->signature->type =~ /Constructor$/) {
     2011                                my $constructorType = $attribute->signature->type;
     2012                                $constructorType =~ s/Constructor$//;
     2013                                # $constructorType ~= /Constructor$/ indicates that it is NamedConstructor.
     2014                                # We do not generate the header file for NamedConstructor of class XXXX,
     2015                                # since we generate the NamedConstructor declaration into the header file of class XXXX.
     2016                                if ($constructorType ne "DOMObject" and $constructorType !~ /Constructor$/) {
     2017                                    AddToImplIncludes("JS" . $constructorType . ".h", $attribute->signature->extendedAttributes->{"Conditional"});
     2018                                }
     2019                                push(@implContent, "    // Shadowing a built-in constructor\n");
     2020                                if ($interfaceName eq "DOMWindow" && $className eq "JSblah") {
     2021                                    # FIXME: This branch never executes and should be removed.
     2022                                    push(@implContent, "    jsCast<$className*>(thisObject)->putDirect(exec->globalData(), exec->propertyNames().constructor, value);\n");
     2023                                } else {
     2024                                    push(@implContent, "    jsCast<$className*>(thisObject)->putDirect(exec->globalData(), Identifier(exec, \"$name\"), value);\n");
     2025                                }
     2026                            } elsif ($attribute->signature->extendedAttributes->{"Replaceable"}) {
     2027                                push(@implContent, "    // Shadowing a built-in object\n");
     2028                                push(@implContent, "    jsCast<$className*>(thisObject)->putDirect(exec->globalData(), Identifier(exec, \"$name\"), value);\n");
    19202029                            } else {
    1921                                 push(@implContent, "    if (!shouldAllowAccessToFrame(exec, jsCast<$className*>(thisObject)->impl()->frame()))\n");
    1922                             }
    1923                             push(@implContent, "        return;\n");
    1924                         }
    1925 
    1926                         if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCustom"} || $attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCustomSetter"}) {
    1927                             push(@implContent, "    jsCast<$className*>(thisObject)->set$implSetterFunctionName(exec, value);\n");
    1928                         } elsif ($type eq "EventListener") {
    1929                             $implIncludes{"JSEventListener.h"} = 1;
    1930                             push(@implContent, "    UNUSED_PARAM(exec);\n");
    1931                             push(@implContent, "    ${className}* castedThis = jsCast<${className}*>(thisObject);\n");
    1932                             my $windowEventListener = $attribute->signature->extendedAttributes->{"JSWindowEventListener"};
    1933                             if ($windowEventListener) {
    1934                                 push(@implContent, "    JSDOMGlobalObject* globalObject = castedThis->globalObject();\n");
    1935                             }
    1936                             push(@implContent, "    $implClassName* impl = static_cast<$implClassName*>(castedThis->impl());\n");
    1937                             if ((($interfaceName eq "DOMWindow") or ($interfaceName eq "WorkerContext")) and $name eq "onerror") {
    1938                                 $implIncludes{"JSErrorHandler.h"} = 1;
    1939                                 push(@implContent, "    impl->set$implSetterFunctionName(createJSErrorHandler(exec, value, thisObject));\n");
    1940                             } else {
    1941                                 push(@implContent, GenerateAttributeEventListenerCall($className, $implSetterFunctionName, $windowEventListener));
    1942                             }
    1943                         } elsif ($attribute->signature->type =~ /Constructor$/) {
    1944                             my $constructorType = $attribute->signature->type;
    1945                             $constructorType =~ s/Constructor$//;
    1946                             # $constructorType ~= /Constructor$/ indicates that it is NamedConstructor.
    1947                             # We do not generate the header file for NamedConstructor of class XXXX,
    1948                             # since we generate the NamedConstructor declaration into the header file of class XXXX.
    1949                             if ($constructorType ne "DOMObject" and $constructorType !~ /Constructor$/) {
    1950                                 AddToImplIncludes("JS" . $constructorType . ".h", $attribute->signature->extendedAttributes->{"Conditional"});
    1951                             }
    1952                             push(@implContent, "    // Shadowing a built-in constructor\n");
    1953                             if ($interfaceName eq "DOMWindow" && $className eq "JSblah") {
    1954                                 # FIXME: This branch never executes and should be removed.
    1955                                 push(@implContent, "    jsCast<$className*>(thisObject)->putDirect(exec->globalData(), exec->propertyNames().constructor, value);\n");
    1956                             } else {
    1957                                 push(@implContent, "    jsCast<$className*>(thisObject)->putDirect(exec->globalData(), Identifier(exec, \"$name\"), value);\n");
    1958                             }
    1959                         } elsif ($attribute->signature->extendedAttributes->{"Replaceable"}) {
    1960                             push(@implContent, "    // Shadowing a built-in object\n");
    1961                             push(@implContent, "    jsCast<$className*>(thisObject)->putDirect(exec->globalData(), Identifier(exec, \"$name\"), value);\n");
    1962                         } else {
    1963                             push(@implContent, "    $className* castedThis = jsCast<$className*>(thisObject);\n");
    1964                             push(@implContent, "    $implType* impl = static_cast<$implType*>(castedThis->impl());\n");
    1965                             push(@implContent, "    ExceptionCode ec = 0;\n") if @{$attribute->setterExceptions};
    1966 
    1967                             # If the "StrictTypeChecking" extended attribute is present, and the attribute's type is an
    1968                             # interface type, then if the incoming value does not implement that interface, a TypeError
    1969                             # is thrown rather than silently passing NULL to the C++ code.
    1970                             # Per the Web IDL and ECMAScript specifications, incoming values can always be converted to
    1971                             # both strings and numbers, so do not throw TypeError if the attribute is of these types.
    1972                             if ($attribute->signature->extendedAttributes->{"StrictTypeChecking"}) {
    1973                                 $implIncludes{"<runtime/Error.h>"} = 1;
    1974 
    1975                                 my $argType = $attribute->signature->type;
    1976                                 if (!IsNativeType($argType)) {
    1977                                     push(@implContent, "    if (!value.isUndefinedOrNull() && !value.inherits(&JS${argType}::s_info)) {\n");
    1978                                     push(@implContent, "        throwVMTypeError(exec);\n");
    1979                                     push(@implContent, "        return;\n");
    1980                                     push(@implContent, "    };\n");
     2030                                push(@implContent, "    $className* castedThis = jsCast<$className*>(thisObject);\n");
     2031                                push(@implContent, "    $implType* impl = static_cast<$implType*>(castedThis->impl());\n");
     2032                                push(@implContent, "    ExceptionCode ec = 0;\n") if @{$attribute->setterExceptions};
     2033
     2034                                # If the "StrictTypeChecking" extended attribute is present, and the attribute's type is an
     2035                                # interface type, then if the incoming value does not implement that interface, a TypeError
     2036                                # is thrown rather than silently passing NULL to the C++ code.
     2037                                # Per the Web IDL and ECMAScript specifications, incoming values can always be converted to
     2038                                # both strings and numbers, so do not throw TypeError if the attribute is of these types.
     2039                                if ($attribute->signature->extendedAttributes->{"StrictTypeChecking"}) {
     2040                                    $implIncludes{"<runtime/Error.h>"} = 1;
     2041
     2042                                    my $argType = $attribute->signature->type;
     2043                                    if (!IsNativeType($argType)) {
     2044                                        push(@implContent, "    if (!value.isUndefinedOrNull() && !value.inherits(&JS${argType}::s_info)) {\n");
     2045                                        push(@implContent, "        throwVMTypeError(exec);\n");
     2046                                        push(@implContent, "        return;\n");
     2047                                        push(@implContent, "    };\n");
     2048                                    }
    19812049                                }
    1982                             }
    1983 
    1984                             my $nativeValue = JSValueToNative($attribute->signature, "value");
    1985                             if ($svgPropertyOrListPropertyType) {
    1986                                 if ($svgPropertyType) {
    1987                                     push(@implContent, "    if (impl->isReadOnly()) {\n");
    1988                                     push(@implContent, "        setDOMException(exec, NO_MODIFICATION_ALLOWED_ERR);\n");
    1989                                     push(@implContent, "        return;\n");
    1990                                     push(@implContent, "    }\n");
    1991                                     $implIncludes{"ExceptionCode.h"} = 1;
    1992                                 }
    1993                                 push(@implContent, "    $svgPropertyOrListPropertyType& podImpl = impl->propertyReference();\n");
    1994                                 if ($svgPropertyOrListPropertyType eq "float") { # Special case for JSSVGNumber
    1995                                     push(@implContent, "    podImpl = $nativeValue;\n");
     2050
     2051                                my $nativeValue = JSValueToNative($attribute->signature, "value");
     2052                                if ($svgPropertyOrListPropertyType) {
     2053                                    if ($svgPropertyType) {
     2054                                        push(@implContent, "    if (impl->isReadOnly()) {\n");
     2055                                        push(@implContent, "        setDOMException(exec, NO_MODIFICATION_ALLOWED_ERR);\n");
     2056                                        push(@implContent, "        return;\n");
     2057                                        push(@implContent, "    }\n");
     2058                                        $implIncludes{"ExceptionCode.h"} = 1;
     2059                                    }
     2060                                    push(@implContent, "    $svgPropertyOrListPropertyType& podImpl = impl->propertyReference();\n");
     2061                                    if ($svgPropertyOrListPropertyType eq "float") { # Special case for JSSVGNumber
     2062                                        push(@implContent, "    podImpl = $nativeValue;\n");
     2063                                    } else {
     2064                                        push(@implContent, "    podImpl.set$implSetterFunctionName($nativeValue");
     2065                                        push(@implContent, ", ec") if @{$attribute->setterExceptions};
     2066                                        push(@implContent, ");\n");
     2067                                        push(@implContent, "    setDOMException(exec, ec);\n") if @{$attribute->setterExceptions};
     2068                                    }
     2069                                    if ($svgPropertyType) {
     2070                                        if (@{$attribute->setterExceptions}) {
     2071                                            push(@implContent, "    if (!ec)\n");
     2072                                            push(@implContent, "        impl->commitChange();\n");
     2073                                        } else {
     2074                                            push(@implContent, "    impl->commitChange();\n");
     2075                                        }
     2076                                    }
    19962077                                } else {
    1997                                     push(@implContent, "    podImpl.set$implSetterFunctionName($nativeValue");
    1998                                     push(@implContent, ", ec") if @{$attribute->setterExceptions};
    1999                                     push(@implContent, ");\n");
     2078                                    my ($functionName, @arguments) = $codeGenerator->SetterExpression(\%implIncludes, $interfaceName, $attribute);
     2079                                    push(@arguments, $nativeValue);
     2080                                    if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
     2081                                        my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"};
     2082                                        $implIncludes{"${implementedBy}.h"} = 1;
     2083                                        unshift(@arguments, "impl");
     2084                                        $functionName = "${implementedBy}::${functionName}";
     2085                                    } else {
     2086                                        $functionName = "impl->${functionName}";
     2087                                    }
     2088
     2089                                    unshift(@arguments, GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContent, ""));
     2090
     2091                                    push(@arguments, "ec") if @{$attribute->setterExceptions};
     2092                                    push(@implContent, "    ${functionName}(" . join(", ", @arguments) . ");\n");
    20002093                                    push(@implContent, "    setDOMException(exec, ec);\n") if @{$attribute->setterExceptions};
    20012094                                }
    2002                                 if ($svgPropertyType) {
    2003                                     if (@{$attribute->setterExceptions}) {
    2004                                         push(@implContent, "    if (!ec)\n");
    2005                                         push(@implContent, "        impl->commitChange();\n");
    2006                                     } else {
    2007                                         push(@implContent, "    impl->commitChange();\n");
    2008                                     }
    2009                                 }
    2010                             } else {
    2011                                 my ($functionName, @arguments) = $codeGenerator->SetterExpression(\%implIncludes, $interfaceName, $attribute);
    2012                                 push(@arguments, $nativeValue);
    2013                                 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
    2014                                     my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"};
    2015                                     $implIncludes{"${implementedBy}.h"} = 1;
    2016                                     unshift(@arguments, "impl");
    2017                                     $functionName = "${implementedBy}::${functionName}";
    2018                                 } else {
    2019                                     $functionName = "impl->${functionName}";
    2020                                 }
    2021 
    2022                                 unshift(@arguments, GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContent, ""));
    2023 
    2024                                 push(@arguments, "ec") if @{$attribute->setterExceptions};
    2025                                 push(@implContent, "    ${functionName}(" . join(", ", @arguments) . ");\n");
    2026                                 push(@implContent, "    setDOMException(exec, ec);\n") if @{$attribute->setterExceptions};
    20272095                            }
    20282096                        }
  • trunk/Source/WebCore/bindings/scripts/IDLParser.pm

    r121714 r122912  
    338338                $line =~ /$IDLStructure::interfaceAttributeSelector/;
    339339
    340                 my $attributeType = (defined($1) ? $1 : die("Parsing error!\nSource:\n$line\n)"));
    341                 my $attributeExtendedAttributes = (defined($2) ? $2 : " "); chop($attributeExtendedAttributes);
    342 
    343                 my $attributeDataType = (defined($3) ? $3 : die("Parsing error!\nSource:\n$line\n)"));
    344                 my $attributeDataName = (defined($4) ? $4 : die("Parsing error!\nSource:\n$line\n)"));
     340                my $isStatic = defined($1);
     341                my $attributeType = (defined($2) ? $2 : die("Parsing error!\nSource:\n$line\n)"));
     342                my $attributeExtendedAttributes = (defined($3) ? $3 : " "); chop($attributeExtendedAttributes);
     343
     344                my $attributeDataType = (defined($4) ? $4 : die("Parsing error!\nSource:\n$line\n)"));
     345                my $attributeDataName = (defined($5) ? $5 : die("Parsing error!\nSource:\n$line\n)"));
    345346 
    346347                ('' =~ /^/); # Reset variables needed for regexp matching
     
    354355                my $newDataNode = new domAttribute();
    355356                $newDataNode->type($attributeType);
     357                $newDataNode->isStatic($isStatic);
    356358                $newDataNode->signature(new domSignature());
    357359
     
    363365                push(@$arrayRef, $newDataNode);
    364366
    365                 print "  |  |>  Attribute; TYPE \"$attributeType\" DATA NAME \"$attributeDataName\" DATA TYPE \"$attributeDataType\" GET EXCEPTION? \"$getterException\" SET EXCEPTION? \"$setterException\"" .
     367                print "  |  |>  Attribute; STATIC? \"$isStatic\" TYPE \"$attributeType\" DATA NAME \"$attributeDataName\" DATA TYPE \"$attributeDataType\" GET EXCEPTION? \"$getterException\" SET EXCEPTION? \"$setterException\"" .
    366368                    dumpExtendedAttributes("\n  |                 ", $newDataNode->signature->extendedAttributes) . "\n" unless $beQuiet;
    367369
     
    392394                $newDataNode->signature->extendedAttributes(parseExtendedAttributes($methodExtendedAttributes));
    393395
    394                 print "  |  |-  Method; TYPE \"$methodType\" NAME \"$methodName\" EXCEPTION? \"$methodException\"" .
     396                print "  |  |-  Method; STATIC? \"$isStatic\" TYPE \"$methodType\" NAME \"$methodName\" EXCEPTION? \"$methodException\"" .
    395397                    dumpExtendedAttributes("\n  |              ", $newDataNode->signature->extendedAttributes) . "\n" unless $beQuiet;
    396398
  • trunk/Source/WebCore/bindings/scripts/IDLStructure.pm

    r121714 r122912  
    5656struct( domAttribute => {
    5757    type => '$',              # Attribute type (including namespace)
     58    isStatic => '$',
    5859    signature => '$',         # Attribute signature
    5960    getterExceptions => '@',  # Possibly raised exceptions.
     
    111112our $interfaceParameterSelector = '(in|out)\s*((?:' . $extendedAttributeSyntax . ' )?)' . $supportedTypes . $supportedTypeSuffix . '\s*(' . $idlIdNs . '*)';
    112113
    113 our $interfaceAttributeSelector = '\s*(readonly attribute|attribute)\s*(' . $extendedAttributeSyntax . ' )?' . $supportedTypes . '\s*(' . $idlType . '*)';
     114our $interfaceAttributeSelector = '\s*(static\s+)?(readonly attribute|attribute)\s*(' . $extendedAttributeSyntax . ' )?' . $supportedTypes . '\s*(' . $idlType . '*)';
    114115
    1151161;
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r121817 r122912  
    167167    { "CONST_VALUE_14", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_VALUE_14), (intptr_t)0, NoIntrinsic },
    168168    { "CONST_JAVASCRIPT", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_JAVASCRIPT), (intptr_t)0, NoIntrinsic },
     169    { "staticReadOnlyIntAttr", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConstructorStaticReadOnlyIntAttr), (intptr_t)0, NoIntrinsic },
     170    { "staticStringAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConstructorStaticStringAttr), (intptr_t)setJSTestObjConstructorStaticStringAttr, NoIntrinsic },
    169171    { "classMethod", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjConstructorFunctionClassMethod), (intptr_t)0, NoIntrinsic },
    170172    { "classMethodWithOptional", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjConstructorFunctionClassMethodWithOptional), (intptr_t)1, NoIntrinsic },
     
    412414
    413415
     416JSValue jsTestObjConstructorStaticReadOnlyIntAttr(ExecState* exec, JSValue, PropertyName)
     417{
     418    ScriptExecutionContext* scriptContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();
     419    if (!scriptContext)
     420        return jsUndefined();
     421    JSC::JSValue result = jsNumber(TestObj::staticReadOnlyIntAttr(scriptContext));
     422    return result;
     423}
     424
     425
     426JSValue jsTestObjConstructorStaticStringAttr(ExecState* exec, JSValue, PropertyName)
     427{
     428    ScriptExecutionContext* scriptContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();
     429    if (!scriptContext)
     430        return jsUndefined();
     431    JSC::JSValue result = jsString(exec, TestObj::staticStringAttr(scriptContext));
     432    return result;
     433}
     434
     435
    414436JSValue jsTestObjShortAttr(ExecState* exec, JSValue slotBase, PropertyName)
    415437{
     
    914936    lookupPut<JSTestObj, Base>(exec, propertyName, value, &JSTestObjTable, thisObject, slot);
    915937}
     938
     939void setJSTestObjConstructorStaticStringAttr(ExecState* exec, JSObject*, JSValue value)
     940{
     941    ScriptExecutionContext* scriptContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();
     942    if (!scriptContext)
     943        return;
     944    TestObj::setStaticStringAttr(scriptContext, ustringToString(value.isEmpty() ? UString() : value.toString(exec)->value(exec)));
     945}
     946
    916947
    917948void setJSTestObjShortAttr(ExecState* exec, JSObject* thisObject, JSValue value)
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h

    r120304 r122912  
    221221JSC::JSValue jsTestObjReadOnlyStringAttr(JSC::ExecState*, JSC::JSValue, JSC::PropertyName);
    222222JSC::JSValue jsTestObjReadOnlyTestObjAttr(JSC::ExecState*, JSC::JSValue, JSC::PropertyName);
     223JSC::JSValue jsTestObjConstructorStaticReadOnlyIntAttr(JSC::ExecState*, JSC::JSValue, JSC::PropertyName);
     224JSC::JSValue jsTestObjConstructorStaticStringAttr(JSC::ExecState*, JSC::JSValue, JSC::PropertyName);
     225void setJSTestObjConstructorStaticStringAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue);
    223226JSC::JSValue jsTestObjShortAttr(JSC::ExecState*, JSC::JSValue, JSC::PropertyName);
    224227void setJSTestObjShortAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue);
  • trunk/Source/WebCore/bindings/scripts/test/TestObj.idl

    r121817 r122912  
    3939        readonly attribute DOMString       readOnlyStringAttr;
    4040        readonly attribute TestObj         readOnlyTestObjAttr;
     41#if defined(TESTING_JS)
     42        static readonly attribute long     staticReadOnlyIntAttr;
     43        static attribute DOMString         staticStringAttr;
     44#endif
    4145        attribute short                    shortAttr;
    4246        attribute unsigned short           unsignedShortAttr;
Note: See TracChangeset for help on using the changeset viewer.