Improve IDL support for object arguments that are neither optional nor nullable
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 Apr 2016 03:46:25 +0000 (03:46 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 Apr 2016 03:46:25 +0000 (03:46 +0000)
commit4a9c9bf1ce5c7a6f31bd9deebc5d09727dda43b0
tree6192cae754a1d8a698fbe8dd1bf0e18327c81784
parente0f541cf8446a8384abae78f8dd15b1b180609a8
Improve IDL support for object arguments that are neither optional nor nullable
https://bugs.webkit.org/show_bug.cgi?id=156149

Reviewed by Chris Dumez.

Source/WebCore:

After this patch, we are almost ready to change some more DOM functions to
use references instead of pointers. Remaining blocking issue is lack of support
for ShouldPassWrapperByReference in the gobject bindings.

* bindings/objc/ExceptionHandlers.h: Add NO_RETURN to raiseDOMException.
Added a new raiseTypeErrorException. Re-indented header and removed unneeded
include and forward declarations.

* bindings/objc/ExceptionHandlers.mm:
(WebCore::raiseDOMException): Added RELEASE_ASSERT_NOT_REACHED so the compiler
will understand this is NO_RETURN. Also updated FIXME comment.
(WebCore::raiseTypeErrorException): Added.

* bindings/scripts/CodeGenerator.pm: Removed unneeded code that allows the type
"AtomicString" in IDL files.
(ShouldPassWrapperByReference): Added. Contains the logic from the function in
the JavaScript code generator that was named IsPointerParameterPassedByReference,
minus a couple checks that are unneeded. For use in other code generators so they
are all consistent about how they call the DOM implementation.

* bindings/scripts/CodeGeneratorGObject.pm:
(SkipFunction): Removed support for unused CustomBinding extended attribute.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateHeader): Removed support for unused CustomBinding extended attribute.
(GenerateImplementation): Ditto. Also changed type checking code to throw a
type error in a more efficient way, using throwVMTypeError directly.
(GenerateParametersCheck): Rearranged code a bit so that arguments that need to
be passed in unusual ways are handled all in one place. Use WTFMove for newly
created NodeFilter objects. Simplified the reference logic so it doesn't need
to do an additional check to see if a type is a callback. Also changed type
checking code to throw a type error in a more efficient way, using throwVMTypeError
directly. Also corrected mistake where null checking code was throwing
TYPE_MISMATCH_ERR instead of a type error.
(GetNativeType): Coding style tweak.
(ShouldPassWrapperByReference): Renamed from IsPointerParameterPassedByReference.
Changed to call underlying ShouldPassWrapperByReference function in the language-
independent code generator.
(GenerateConstructorDefinition): Updated for name change.

* bindings/scripts/CodeGeneratorObjC.pm:
(SkipFunction): Removed support for unused CustomBinding extended attribute.
(GenerateImplementation): Added code to null check and pass a reference when
ShouldPassWrapperByReference returns true.

* bindings/scripts/IDLAttributes.txt: Sorted in the AppleCopyright and
UsePointersEvenForNonNullableObjectArguments arguments. Removed the unused
CPPPureInterface and CustomBinding attributes.

* bindings/scripts/test/JS/JSTestActiveDOMObject.cpp: Regenerated test results.
* bindings/scripts/test/JS/JSTestInterface.cpp: Ditto.
* bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp: Ditto.
* bindings/scripts/test/JS/JSTestObj.cpp: Ditto.
* bindings/scripts/test/JS/JSTestObj.h: Ditto.
* bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp: Ditto.
* bindings/scripts/test/JS/JSTestTypedefs.cpp: Ditto.
* bindings/scripts/test/ObjC/DOMTestActiveDOMObject.mm: Ditto.
* bindings/scripts/test/ObjC/DOMTestCallback.mm: Ditto.
* bindings/scripts/test/ObjC/DOMTestCallbackFunction.mm: Ditto.
* bindings/scripts/test/ObjC/DOMTestInterface.mm: Ditto.
* bindings/scripts/test/ObjC/DOMTestMediaQueryListListener.mm: Ditto.
* bindings/scripts/test/ObjC/DOMTestObj.mm: Ditto.

* bindings/scripts/test/TestObj.idl: Removed test for CustomBinding.

* dom/DOMImplementation.idl: Fixed #if so that only the return type is different
between JavaScript and the other bindings. Without this change, the different
bindings got different results for ShouldPassWrapperByReference. Also formatted
functions all on a single line.

* dom/EventListener.idl: Removed CPPPureInterface, since it had no effect.
* dom/EventTarget.idl: Ditto.

LayoutTests:

* fast/canvas/canvas-path-addPath-expected.txt: Updated expected result to expect
TypeError rather than TYPE_MISMATCH_ERR. A progression.
* fast/text/font-face-set-javascript-expected.txt: Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@199265 268f45cc-cd09-0410-ab3c-d52691b4dbfc
28 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/canvas/canvas-path-addPath-expected.txt
LayoutTests/fast/text/font-face-set-javascript-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/bindings/objc/ExceptionHandlers.h
Source/WebCore/bindings/objc/ExceptionHandlers.mm
Source/WebCore/bindings/scripts/CodeGenerator.pm
Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm
Source/WebCore/bindings/scripts/IDLAttributes.txt
Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestObj.h
Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp
Source/WebCore/bindings/scripts/test/ObjC/DOMTestActiveDOMObject.mm
Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm
Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallbackFunction.mm
Source/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.mm
Source/WebCore/bindings/scripts/test/ObjC/DOMTestMediaQueryListListener.mm
Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm
Source/WebCore/bindings/scripts/test/TestObj.idl
Source/WebCore/dom/DOMImplementation.idl
Source/WebCore/dom/EventListener.idl
Source/WebCore/dom/EventTarget.idl