Bindings generator emits incorrect code when using VoidCallback as an IDL dictionary...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Jan 2019 21:46:30 +0000 (21:46 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Jan 2019 21:46:30 +0000 (21:46 +0000)
commitc4ad89878c2fe5e5aa316178d81d2b87477e419a
treee418bf8848db40186c99223c15819f20c4c054fc
parentc06483e82ef0654e2112c6000f30550a0a14ab23
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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239842 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp
Source/WebCore/bindings/scripts/test/TestStandaloneDictionary.idl