Title: [239842] trunk/Source/WebCore
- Revision
- 239842
- Author
- wenson_hs...@apple.com
- Date
- 2019-01-10 13:46:30 -0800 (Thu, 10 Jan 2019)
Log Message
Bindings generator emits incorrect code when using VoidCallback as an IDL dictionary attribute
https://bugs.webkit.org/show_bug.cgi?id=193328
Reviewed by Chris Dumez.
Currently, when generating the function body of `convertDictionary`, our bindings generator does not pass in an
argument to use as the `$globalObjectReference` in `JSValueToNative`, when generating code to convert a wrapped
attribute value to the native value. As a result, if the generated IDL type returns `true` from
`JSValueToNativeDOMConvertNeedsGlobalObject` (i.e. for callback function types), we will end up using the empty
string as the generated _expression_ for the global object. This emits syntactically incorrect code:
`convert<IDLCallbackFunction<JSVoidCallback>>(state, someValue, );`
To fix this, we pass in a string to use as the global object, which uses the given ExecState to grab the global
object. Tested by augmenting TestStandaloneDictionary.idl and its generated expectation.
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateDictionaryImplementationContent):
* bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp:
(WebCore::convertDictionary<DictionaryImplName>):
* bindings/scripts/test/TestStandaloneDictionary.idl:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (239841 => 239842)
--- trunk/Source/WebCore/ChangeLog 2019-01-10 21:23:00 UTC (rev 239841)
+++ trunk/Source/WebCore/ChangeLog 2019-01-10 21:46:30 UTC (rev 239842)
@@ -1,3 +1,27 @@
+2019-01-10 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Bindings generator emits incorrect code when using VoidCallback as an IDL dictionary attribute
+ https://bugs.webkit.org/show_bug.cgi?id=193328
+
+ Reviewed by Chris Dumez.
+
+ Currently, when generating the function body of `convertDictionary`, our bindings generator does not pass in an
+ argument to use as the `$globalObjectReference` in `JSValueToNative`, when generating code to convert a wrapped
+ attribute value to the native value. As a result, if the generated IDL type returns `true` from
+ `JSValueToNativeDOMConvertNeedsGlobalObject` (i.e. for callback function types), we will end up using the empty
+ string as the generated _expression_ for the global object. This emits syntactically incorrect code:
+
+ `convert<IDLCallbackFunction<JSVoidCallback>>(state, someValue, );`
+
+ To fix this, we pass in a string to use as the global object, which uses the given ExecState to grab the global
+ object. Tested by augmenting TestStandaloneDictionary.idl and its generated expectation.
+
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GenerateDictionaryImplementationContent):
+ * bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp:
+ (WebCore::convertDictionary<DictionaryImplName>):
+ * bindings/scripts/test/TestStandaloneDictionary.idl:
+
2019-01-10 Eric Carlson <eric.carl...@apple.com>
Define page media state flags for display capture.
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (239841 => 239842)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2019-01-10 21:23:00 UTC (rev 239841)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2019-01-10 21:46:30 UTC (rev 239842)
@@ -2348,7 +2348,7 @@
# 4.3. If value is not undefined, then:
$result .= " if (!${key}Value.isUndefined()) {\n";
- my $nativeValue = JSValueToNative($typeScope, $member, "${key}Value", $member->extendedAttributes->{Conditional}, "&state", "state");
+ my $nativeValue = JSValueToNative($typeScope, $member, "${key}Value", $member->extendedAttributes->{Conditional}, "&state", "state", "", "*jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject())");
$result .= " result.$implementedAsKey = $nativeValue;\n";
$result .= " RETURN_IF_EXCEPTION(throwScope, { });\n";
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp (239841 => 239842)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp 2019-01-10 21:23:00 UTC (rev 239841)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp 2019-01-10 21:46:30 UTC (rev 239842)
@@ -25,7 +25,10 @@
#include "JSTestStandaloneDictionary.h"
#include "JSDOMConvertBoolean.h"
+#include "JSDOMConvertCallbacks.h"
#include "JSDOMConvertStrings.h"
+#include "JSDOMGlobalObject.h"
+#include "JSVoidCallback.h"
#include <_javascript_Core/JSCInlines.h>
#include <_javascript_Core/JSString.h>
#include <wtf/NeverDestroyed.h>
@@ -58,6 +61,17 @@
result.boolMember = convert<IDLBoolean>(state, boolMemberValue);
RETURN_IF_EXCEPTION(throwScope, { });
}
+ JSValue callbackMemberValue;
+ if (isNullOrUndefined)
+ callbackMemberValue = jsUndefined();
+ else {
+ callbackMemberValue = object->get(&state, Identifier::fromString(&state, "callbackMember"));
+ RETURN_IF_EXCEPTION(throwScope, { });
+ }
+ if (!callbackMemberValue.isUndefined()) {
+ result.callbackMember = convert<IDLCallbackFunction<JSVoidCallback>>(state, callbackMemberValue, *jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject()));
+ RETURN_IF_EXCEPTION(throwScope, { });
+ }
JSValue enumMemberValue;
if (isNullOrUndefined)
enumMemberValue = jsUndefined();
Modified: trunk/Source/WebCore/bindings/scripts/test/TestStandaloneDictionary.idl (239841 => 239842)
--- trunk/Source/WebCore/bindings/scripts/test/TestStandaloneDictionary.idl 2019-01-10 21:23:00 UTC (rev 239841)
+++ trunk/Source/WebCore/bindings/scripts/test/TestStandaloneDictionary.idl 2019-01-10 21:46:30 UTC (rev 239842)
@@ -36,4 +36,5 @@
boolean boolMember;
DOMString stringMember;
TestEnumInStandaloneDictionaryFile enumMember;
+ VoidCallback callbackMember;
};
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes