[WebIDL] Remove the need for the generator to know about native type mapping
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 May 2017 18:07:49 +0000 (18:07 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 May 2017 18:07:49 +0000 (18:07 +0000)
commit41b924904c1283d93865211f49a30bb594d79e32
tree3f8323cd222a1bc5ad2a79bc15f43a7e68844116
parentbf4c4e38e9deaa4a7d00233a9209e902ad31ebdd
[WebIDL] Remove the need for the generator to know about native type mapping
https://bugs.webkit.org/show_bug.cgi?id=172310

Reviewed by Darin Adler.

Source/WebCore:

Replace the use of explicit typename to native type mappings in CodeGeneratorJS.pm
with use of IDLTypes and Converter, which already need the mapping. This allows us
to have the information in only one spot.

Also, callback generation to account for nullability and update the IDLs to correctly
annotate only the types that need to be nullable.

* Modules/geolocation/GeoNotifier.cpp:
* Modules/geolocation/GeoNotifier.h:
* Modules/geolocation/Geolocation.cpp:
* Modules/geolocation/Geolocation.h:
* Modules/geolocation/PositionCallback.idl:
* Modules/geolocation/PositionErrorCallback.h:
Use references where possible in the Geolocation code. It was almost possible
to make PositionCallback take a non-nullable position, but some odd logic in
Geolocation::makeCachedPositionCallbacks() implies that there is a path where
passing null is possible, though it would assert. Added FIXME's to return to
this in a follow up.

* Modules/webaudio/AudioBufferCallback.idl:
Add nullable annotation and FIXME explaining that the latest spec splits the callback
into two separate ones.

* Modules/webdatabase/Database.cpp:
(WebCore::Database::runTransaction):
* Modules/webdatabase/DatabaseCallback.h:
* Modules/webdatabase/DatabaseManager.cpp:
(WebCore::DatabaseManager::openDatabase):
* Modules/webdatabase/SQLStatement.cpp:
(WebCore::SQLStatement::performCallback):
* Modules/webdatabase/SQLStatementCallback.h:
* Modules/webdatabase/SQLStatementErrorCallback.h:
* Modules/webdatabase/SQLTransaction.cpp:
(WebCore::SQLTransaction::deliverTransactionCallback):
(WebCore::SQLTransaction::deliverTransactionErrorCallback):
* Modules/webdatabase/SQLTransactionCallback.h:
* Modules/webdatabase/SQLTransactionErrorCallback.h:
* inspector/InspectorDatabaseAgent.cpp:
* bindings/js/JSSQLStatementErrorCallbackCustom.cpp:
(WebCore::JSSQLStatementErrorCallback::handleEvent):
Update to pass callback parameters as references, since they are never null.

* bindings/IDLTypes.h:
Add NullableParameterType to allow customization of nullable parameters (in much
the same way we allow customization of the nullable implementation type).

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateDefaultValue):
Use Converter<>::ReturnType{ } for default values rather than ${GetNativeType..}().

(GenerateHeader):
Remove use of GetNativeType for toWrapped by using the impl type, since this will never
be a complex type.

(GenerateImplementation):
Simplify DOMJIT UnsafeToNative by merging two identical paths and using auto.

(GenerateParametersCheck):
Rework parameter checks to use more specific variable names, make branches more clear,
and use Converter<>::ReturnType rather than GetNativeType.

(GenerateCallbackHeaderContent):
(GenerateCallbackImplementationContent):
Switch to using typename ${IDLType}::ParameterType as the parameters for callback functions. Also
add final and override to make sure the generated function matches the user provided base class.
(GetNativeType): Deleted.
(GetNativeInnerType): Deleted.
(GetNativeTypeForCallbacks): Deleted.
Remove native type mappings.

* css/MediaQueryListListener.h:
* css/MediaQueryListListener.idl:
* css/MediaQueryMatcher.cpp:
Update MediaQueryListListener to take a non-nullable MediaQueryList.

* dom/NativeNodeFilter.cpp:
* dom/NativeNodeFilter.h:
* dom/NodeFilter.h:
* dom/NodeFilter.idl:
* dom/NodeIterator.cpp:
* dom/Traversal.cpp:
* dom/Traversal.h:
* dom/TreeWalker.cpp:
* bindings/js/JSNodeFilterCustom.cpp:
Update acceptNode to be non-nullable and pass the Node by reference.

* dom/StringCallback.cpp:
* dom/StringCallback.h:
Pass the ScriptExecutionContext by reference.

* page/IntersectionObserverCallback.h:
Update to match new parameter types and pass IntersectionObserver by reference.

* page/PerformanceObserver.cpp:
* page/PerformanceObserverCallback.h:
Update to pass PerformanceObserverEntryList and PerformanceObserver by reference.

* bindings/scripts/test/JS/JSTestCallbackFunction.cpp:
* bindings/scripts/test/JS/JSTestCallbackFunction.h:
* bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.cpp:
* bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.h:
* bindings/scripts/test/JS/JSTestCallbackInterface.cpp:
* bindings/scripts/test/JS/JSTestCallbackInterface.h:
* bindings/scripts/test/JS/JSTestObj.cpp:
* bindings/scripts/test/JS/JSTestTypedefs.cpp:
Update test results.

* bindings/scripts/test/TestCallbackInterface.idl:
Update test to refer to actual interfaces as we now do lookup on these parameter
types rather than blindly assuming they are interfaces.

Source/WebKit/mac:

* DOM/DOM.mm:
(-[DOMNodeFilter acceptNode:]):
Update to pass Node by reference.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@217134 268f45cc-cd09-0410-ab3c-d52691b4dbfc
49 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/geolocation/GeoNotifier.cpp
Source/WebCore/Modules/geolocation/GeoNotifier.h
Source/WebCore/Modules/geolocation/Geolocation.cpp
Source/WebCore/Modules/geolocation/Geolocation.h
Source/WebCore/Modules/geolocation/PositionCallback.idl
Source/WebCore/Modules/geolocation/PositionErrorCallback.h
Source/WebCore/Modules/webaudio/AudioBufferCallback.idl
Source/WebCore/Modules/webdatabase/Database.cpp
Source/WebCore/Modules/webdatabase/DatabaseCallback.h
Source/WebCore/Modules/webdatabase/DatabaseManager.cpp
Source/WebCore/Modules/webdatabase/SQLStatement.cpp
Source/WebCore/Modules/webdatabase/SQLStatementCallback.h
Source/WebCore/Modules/webdatabase/SQLStatementErrorCallback.h
Source/WebCore/Modules/webdatabase/SQLTransaction.cpp
Source/WebCore/Modules/webdatabase/SQLTransactionCallback.h
Source/WebCore/Modules/webdatabase/SQLTransactionErrorCallback.h
Source/WebCore/bindings/IDLTypes.h
Source/WebCore/bindings/js/JSNodeFilterCustom.cpp
Source/WebCore/bindings/js/JSSQLStatementErrorCallbackCustom.cpp
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunction.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunction.h
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.h
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.h
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp
Source/WebCore/bindings/scripts/test/TestCallbackInterface.idl
Source/WebCore/css/MediaQueryListListener.h
Source/WebCore/css/MediaQueryListListener.idl
Source/WebCore/css/MediaQueryMatcher.cpp
Source/WebCore/dom/NativeNodeFilter.cpp
Source/WebCore/dom/NativeNodeFilter.h
Source/WebCore/dom/NodeFilter.h
Source/WebCore/dom/NodeFilter.idl
Source/WebCore/dom/NodeIterator.cpp
Source/WebCore/dom/StringCallback.cpp
Source/WebCore/dom/StringCallback.h
Source/WebCore/dom/Traversal.cpp
Source/WebCore/dom/Traversal.h
Source/WebCore/dom/TreeWalker.cpp
Source/WebCore/inspector/InspectorDatabaseAgent.cpp
Source/WebCore/page/IntersectionObserverCallback.h
Source/WebCore/page/PerformanceObserver.cpp
Source/WebCore/page/PerformanceObserverCallback.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/DOM/DOM.mm