Title: [156157] trunk/Source/WebCore
Revision
156157
Author
[email protected]
Date
2013-09-20 06:16:28 -0700 (Fri, 20 Sep 2013)

Log Message

StrictTypeChecking extended attribute fails for methods with sequence<T> https://bugs.webkit.org/show_bug.cgi?id=121305

Reviewed by Darin Adler.
Patch by Antonio Gomes <[email protected]>

The extended attribute StrictTypeChecking can not be set to methods if
one of the parameters is a "sequence".
Basically, since "sequence" is not considered a native type
(see function IsNativeType) the Perl code generator tries to
include its supposedly associated header, in this case "JSsequence.h"
Compilation then fails.

It is a problem for bindings including WebGL, where all methods
are supposed to be set as StrictTypeChecking (see bug 44202 [1]). Due to this restriction,
it relaxed, but I would like to bring it back.

Patch fixes the issue by hardening the way includes are auto-added
for methods where StrictTypeChecking extended attribute is present.
Now, only wrapper types (see IsWrapperType) trigger header inclusion,
excluding arrays, sequences, basic types, etc.

[1] https://bugs.webkit.org/show_bug.cgi?id=44202

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateParametersCheck):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::jsTestObjPrototypeFunctionStrictFunctionWithSequence):
* bindings/scripts/test/JS/JSTestObj.h:
* bindings/scripts/test/TestObj.idl:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (156156 => 156157)


--- trunk/Source/WebCore/ChangeLog	2013-09-20 12:28:36 UTC (rev 156156)
+++ trunk/Source/WebCore/ChangeLog	2013-09-20 13:16:28 UTC (rev 156157)
@@ -1,3 +1,35 @@
+2013-09-16  Antonio Gomes  <[email protected]>
+
+        StrictTypeChecking extended attribute fails for methods with sequence<T>
+        https://bugs.webkit.org/show_bug.cgi?id=121305
+
+        Reviewed by Darin Adler.
+
+        The extended attribute StrictTypeChecking can not be set to methods if
+        one of the parameters is a "sequence".
+        Basically, since "sequence" is not considered a native type
+        (see function IsNativeType) the Perl code generator tries to
+        include its supposedly associated header, in this case "JSsequence.h"
+        Compilation then fails.
+
+        It is a problem for bindings including WebGL, where all methods
+        are supposed to be set as StrictTypeChecking (see bug 44202 [1]). Due to this restriction,
+        it relaxed, but I would like to bring it back.
+
+        Patch fixes the issue by hardening the way includes are auto-added
+        for methods where StrictTypeChecking extended attribute is present.
+        Now, only wrapper types (see IsWrapperType) trigger header inclusion,
+        excluding arrays, sequences, basic types, etc.
+
+        [1] https://bugs.webkit.org/show_bug.cgi?id=44202
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateParametersCheck):
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::jsTestObjPrototypeFunctionStrictFunctionWithSequence):
+        * bindings/scripts/test/JS/JSTestObj.h:
+        * bindings/scripts/test/TestObj.idl:
+
 2013-09-20  Andreas Kling  <[email protected]>
 
         Optimize fetching the Node for never-anonymous renderers.

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (156156 => 156157)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2013-09-20 12:28:36 UTC (rev 156156)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2013-09-20 13:16:28 UTC (rev 156157)
@@ -2193,7 +2193,7 @@
                                     $implIncludes{"<runtime/Error.h>"} = 1;
 
                                     my $argType = $attribute->signature->type;
-                                    if (!IsNativeType($argType)) {
+                                    if ($codeGenerator->IsWrapperType($argType)) {
                                         push(@implContent, "    if (!value.isUndefinedOrNull() && !value.inherits(JS${argType}::info())) {\n");
                                         push(@implContent, "        throwVMTypeError(exec);\n");
                                         push(@implContent, "        return;\n");
@@ -2922,7 +2922,7 @@
                 $implIncludes{"<runtime/Error.h>"} = 1;
 
                 my $argValue = "exec->argument($argsIndex)";
-                if (!IsNativeType($argType)) {
+                if ($codeGenerator->IsWrapperType($argType)) {
                     push(@$outputArray, "    if (exec->argumentCount() > $argsIndex && !${argValue}.isUndefinedOrNull() && !${argValue}.inherits(JS${argType}::info()))\n");
                     push(@$outputArray, "        return throwVMTypeError(exec);\n");
                 }

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (156156 => 156157)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2013-09-20 12:28:36 UTC (rev 156156)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2013-09-20 13:16:28 UTC (rev 156157)
@@ -327,6 +327,8 @@
     { "immutablePointFunction", DontDelete | JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionImmutablePointFunction), (intptr_t)0 },
     { "orange", DontDelete | JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionOrange), (intptr_t)0 },
     { "strictFunction", DontDelete | JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionStrictFunction), (intptr_t)3 },
+    { "strictFunctionWithSequence", DontDelete | JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionStrictFunctionWithSequence), (intptr_t)2 },
+    { "strictFunctionWithArray", DontDelete | JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionStrictFunctionWithArray), (intptr_t)2 },
     { "variadicStringMethod", DontDelete | JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVariadicStringMethod), (intptr_t)2 },
     { "variadicDoubleMethod", DontDelete | JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVariadicDoubleMethod), (intptr_t)2 },
     { "variadicNodeMethod", DontDelete | JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVariadicNodeMethod), (intptr_t)2 },
@@ -3027,6 +3029,56 @@
     return JSValue::encode(result);
 }
 
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionStrictFunctionWithSequence(ExecState* exec)
+{
+    JSValue thisValue = exec->hostThisValue();
+    if (!thisValue.inherits(JSTestObj::info()))
+        return throwVMTypeError(exec);
+    JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue));
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    TestObj* impl = static_cast<TestObj*>(castedThis->impl());
+    if (exec->argumentCount() < 2)
+        return throwVMError(exec, createNotEnoughArgumentsError(exec));
+    ExceptionCode ec = 0;
+    if (exec->argumentCount() > 0 && !exec->argument(0).isUndefinedOrNull() && !exec->argument(0).inherits(JSTestObj::info()))
+        return throwVMTypeError(exec);
+    TestObj* objArg(toTestObj(exec->argument(0)));
+    if (exec->hadException())
+        return JSValue::encode(jsUndefined());
+    Vector<unsigned> a(toNativeArray<unsigned>(exec, exec->argument(1)));
+    if (exec->hadException())
+        return JSValue::encode(jsUndefined());
+
+    JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->strictFunctionWithSequence(objArg, a, ec)));
+    setDOMException(exec, ec);
+    return JSValue::encode(result);
+}
+
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionStrictFunctionWithArray(ExecState* exec)
+{
+    JSValue thisValue = exec->hostThisValue();
+    if (!thisValue.inherits(JSTestObj::info()))
+        return throwVMTypeError(exec);
+    JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue));
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    TestObj* impl = static_cast<TestObj*>(castedThis->impl());
+    if (exec->argumentCount() < 2)
+        return throwVMError(exec, createNotEnoughArgumentsError(exec));
+    ExceptionCode ec = 0;
+    if (exec->argumentCount() > 0 && !exec->argument(0).isUndefinedOrNull() && !exec->argument(0).inherits(JSTestObj::info()))
+        return throwVMTypeError(exec);
+    TestObj* objArg(toTestObj(exec->argument(0)));
+    if (exec->hadException())
+        return JSValue::encode(jsUndefined());
+    Vector<int> array(toNativeArray<int>(exec, exec->argument(1)));
+    if (exec->hadException())
+        return JSValue::encode(jsUndefined());
+
+    JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->strictFunctionWithArray(objArg, array, ec)));
+    setDOMException(exec, ec);
+    return JSValue::encode(result);
+}
+
 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVariadicStringMethod(ExecState* exec)
 {
     JSValue thisValue = exec->hostThisValue();

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h (156156 => 156157)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h	2013-09-20 12:28:36 UTC (rev 156156)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h	2013-09-20 13:16:28 UTC (rev 156157)
@@ -226,6 +226,8 @@
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionImmutablePointFunction(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOrange(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionStrictFunction(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionStrictFunctionWithSequence(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionStrictFunctionWithArray(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVariadicStringMethod(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVariadicDoubleMethod(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVariadicNodeMethod(JSC::ExecState*);

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp (156156 => 156157)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp	2013-09-20 12:28:36 UTC (rev 156156)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp	2013-09-20 13:16:28 UTC (rev 156157)
@@ -354,8 +354,6 @@
         return JSValue::encode(jsUndefined());
     }
 
-    if (exec->argumentCount() > 0 && !exec->argument(0).isUndefinedOrNull() && !exec->argument(0).inherits(JSlong[]::info()))
-        return throwVMTypeError(exec);
     Vector<int> x(toNativeArray<int>(exec, exec->argument(0)));
     if (exec->hadException())
         return JSValue::encode(jsUndefined());

Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (156156 => 156157)


--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2013-09-20 12:28:36 UTC (rev 156156)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2013-09-20 13:16:28 UTC (rev 156157)
@@ -224,6 +224,8 @@
 
     [StrictTypeChecking] attribute float strictFloat;
     [StrictTypeChecking, RaisesException] bool strictFunction(DOMString str, float a, long b);
+    [StrictTypeChecking, RaisesException] bool strictFunctionWithSequence(TestObj objArg, sequence<unsigned long> a);
+    [StrictTypeChecking, RaisesException] bool strictFunctionWithArray(TestObj objArg, long[] array);
 
     // ObjectiveC reserved words.
     readonly attribute long      description;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to