[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)
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

index 9e8a307..001f165 100644 (file)
@@ -1,3 +1,121 @@
+2017-05-18  Sam Weinig  <sam@webkit.org>
+
+        [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.
+
+        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.
+
 2017-05-19  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r217098, r217111, r217113, and
index 869502f..1a28d19 100644 (file)
@@ -79,7 +79,7 @@ void GeoNotifier::runSuccessCallback(Geoposition* position)
     m_successCallback->handleEvent(position);
 }
 
-void GeoNotifier::runErrorCallback(PositionError* error)
+void GeoNotifier::runErrorCallback(PositionError& error)
 {
     if (m_errorCallback)
         m_errorCallback->handleEvent(error);
@@ -106,7 +106,7 @@ void GeoNotifier::timerFired()
     // Test for fatal error first. This is required for the case where the Frame is
     // disconnected and requests are cancelled.
     if (m_fatalError) {
-        runErrorCallback(m_fatalError.get());
+        runErrorCallback(*m_fatalError);
         // This will cause this notifier to be deleted.
         m_geolocation->fatalErrorOccurred(this);
         return;
@@ -121,8 +121,8 @@ void GeoNotifier::timerFired()
     }
     
     if (m_errorCallback) {
-        RefPtr<PositionError> error = PositionError::create(PositionError::TIMEOUT, ASCIILiteral("Timeout expired"));
-        m_errorCallback->handleEvent(error.get());
+        auto error = PositionError::create(PositionError::TIMEOUT, ASCIILiteral("Timeout expired"));
+        m_errorCallback->handleEvent(error);
     }
     m_geolocation->requestTimedOut(this);
 }
index b2d30f3..fb32ce8 100644 (file)
@@ -55,8 +55,8 @@ public:
     bool useCachedPosition() const { return m_useCachedPosition; }
     void setUseCachedPosition();
 
-    void runSuccessCallback(Geoposition*);
-    void runErrorCallback(PositionError*);
+    void runSuccessCallback(Geoposition*); // FIXME: This should take a reference.
+    void runErrorCallback(PositionError&);
 
     void startTimerIfNeeded();
     void stopTimer();
index ebe49b0..32b1155 100644 (file)
@@ -232,7 +232,7 @@ void Geolocation::resumeTimerFired()
     }
 
     if (m_errorWaitingForResume) {
-        handleError(m_errorWaitingForResume.get());
+        handleError(*m_errorWaitingForResume);
         m_errorWaitingForResume = nullptr;
     }
 }
@@ -435,6 +435,8 @@ void Geolocation::makeCachedPositionCallbacks()
     // asynchronously, so we don't need to worry about it being modified from
     // the callbacks.
     for (auto& notifier : m_requestsAwaitingCachedPosition) {
+        // FIXME: This seems wrong, since makeCachedPositionCallbacks() is called in a branch where
+        // lastPosition() is known to be null in Geolocation::setIsAllowed().
         notifier->runSuccessCallback(lastPosition());
 
         // If this is a one-shot request, stop it. Otherwise, if the watch still
@@ -506,35 +508,34 @@ void Geolocation::setIsAllowed(bool allowed)
     }
 
     if (!isAllowed()) {
-        RefPtr<PositionError> error = PositionError::create(PositionError::PERMISSION_DENIED,  ASCIILiteral(permissionDeniedErrorMessage));
+        auto error = PositionError::create(PositionError::PERMISSION_DENIED,  ASCIILiteral(permissionDeniedErrorMessage));
         error->setIsFatal(true);
-        handleError(error.get());
+        handleError(error);
         m_requestsAwaitingCachedPosition.clear();
         m_hasChangedPosition = false;
         m_errorWaitingForResume = nullptr;
-
         return;
     }
 
     // If the service has a last position, use it to call back for all requests.
     // If any of the requests are waiting for permission for a cached position,
     // the position from the service will be at least as fresh.
-    if (lastPosition())
-        makeSuccessCallbacks();
+    if (RefPtr<Geoposition> position = lastPosition())
+        makeSuccessCallbacks(*position);
     else
         makeCachedPositionCallbacks();
 }
 
-void Geolocation::sendError(GeoNotifierVector& notifiers, PositionError* error)
+void Geolocation::sendError(GeoNotifierVector& notifiers, PositionError& error)
 {
     for (auto& notifier : notifiers)
         notifier->runErrorCallback(error);
 }
 
-void Geolocation::sendPosition(GeoNotifierVector& notifiers, Geoposition* position)
+void Geolocation::sendPosition(GeoNotifierVector& notifiers, Geoposition& position)
 {
     for (auto& notifier : notifiers)
-        notifier->runSuccessCallback(position);
+        notifier->runSuccessCallback(&position);
 }
 
 void Geolocation::stopTimer(GeoNotifierVector& notifiers)
@@ -599,10 +600,8 @@ void Geolocation::copyToSet(const GeoNotifierVector& src, GeoNotifierSet& dest)
         dest.add(notifier.get());
 }
 
-void Geolocation::handleError(PositionError* error)
+void Geolocation::handleError(PositionError& error)
 {
-    ASSERT(error);
-    
     GeoNotifierVector oneShotsCopy;
     copyToVector(m_oneShots, oneShotsCopy);
 
@@ -614,7 +613,7 @@ void Geolocation::handleError(PositionError* error)
     // further callbacks to these notifiers.
     GeoNotifierVector oneShotsWithCachedPosition;
     m_oneShots.clear();
-    if (error->isFatal())
+    if (error.isFatal())
         m_watchers.clear();
     else {
         // Don't send non-fatal errors to notifiers due to receive a cached position.
@@ -650,7 +649,7 @@ void Geolocation::requestPermission()
     GeolocationController::from(page)->requestPermission(this);
 }
 
-void Geolocation::makeSuccessCallbacks()
+void Geolocation::makeSuccessCallbacks(Geoposition& position)
 {
     ASSERT(lastPosition());
     ASSERT(isAllowed());
@@ -666,8 +665,8 @@ void Geolocation::makeSuccessCallbacks()
     // further callbacks to these notifiers.
     m_oneShots.clear();
 
-    sendPosition(oneShotsCopy, lastPosition());
-    sendPosition(watchersCopy, lastPosition());
+    sendPosition(oneShotsCopy, position);
+    sendPosition(watchersCopy, position);
 
     if (!hasListeners())
         stopUpdating();
@@ -685,7 +684,10 @@ void Geolocation::positionChanged()
         return;
     }
 
-    makeSuccessCallbacks();
+    RefPtr<Geoposition> position = lastPosition();
+    ASSERT(position);
+
+    makeSuccessCallbacks(*position);
 }
 
 void Geolocation::setError(GeolocationError* error)
@@ -694,8 +696,9 @@ void Geolocation::setError(GeolocationError* error)
         m_errorWaitingForResume = createPositionError(error);
         return;
     }
-    RefPtr<PositionError> positionError = createPositionError(error);
-    handleError(positionError.get());
+
+    auto positionError = createPositionError(error);
+    handleError(positionError);
 }
 
 bool Geolocation::startUpdating(GeoNotifier* notifier)
index 3396cdc..4b428c0 100644 (file)
@@ -111,8 +111,8 @@ private:
 
     bool hasListeners() const { return !m_oneShots.isEmpty() || !m_watchers.isEmpty(); }
 
-    void sendError(GeoNotifierVector&, PositionError*);
-    void sendPosition(GeoNotifierVector&, Geoposition*);
+    void sendError(GeoNotifierVector&, PositionError&);
+    void sendPosition(GeoNotifierVector&, Geoposition&);
 
     static void extractNotifiersWithCachedPosition(GeoNotifierVector& notifiers, GeoNotifierVector* cached);
     static void copyToSet(const GeoNotifierVector&, GeoNotifierSet&);
@@ -125,8 +125,8 @@ private:
     void cancelRequests(GeoNotifierVector&);
     void cancelAllRequests();
 
-    void makeSuccessCallbacks();
-    void handleError(PositionError*);
+    void makeSuccessCallbacks(Geoposition&);
+    void handleError(PositionError&);
 
     void requestPermission();
 
index e2ce962..ad661f5 100644 (file)
@@ -24,4 +24,4 @@
 
 [
     Conditional=GEOLOCATION,
-] callback PositionCallback = void (Geoposition position);
+] callback PositionCallback = void (Geoposition? position); // FIXME: This should not be nullable.
index 79650b5..4eab9a1 100644 (file)
@@ -34,7 +34,7 @@ namespace WebCore {
     class PositionErrorCallback : public RefCounted<PositionErrorCallback> {
     public:
         virtual ~PositionErrorCallback() { }
-        virtual bool handleEvent(PositionError*) = 0;
+        virtual bool handleEvent(PositionError&) = 0;
     };
 
 } // namespace WebCore
index 74577fd..18d0853 100644 (file)
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+// FIXME: According to the latest WebAudio spec, this should be split into two
+// callbacks, DecodeSuccessCallback which takes a non-nullable AudioBuffer, and
+// DecodeErrorCallback, which takes DOMException. Currently, we pass an AudioBuffer
+// on success and null on failure.
+
 [
     Conditional=WEB_AUDIO,
     JSGenerateToJSObject,
-] callback AudioBufferCallback = void (AudioBuffer audioBuffer);
+] callback AudioBufferCallback = void (AudioBuffer? audioBuffer);
index 0ff586c..31a89af 100644 (file)
@@ -682,7 +682,7 @@ void Database::runTransaction(RefPtr<SQLTransactionCallback>&& callback, RefPtr<
         if (errorCallback) {
             RefPtr<SQLTransactionErrorCallback> errorCallbackProtector = WTFMove(errorCallback);
             m_scriptExecutionContext->postTask([errorCallbackProtector](ScriptExecutionContext&) {
-                errorCallbackProtector->handleEvent(SQLError::create(SQLError::UNKNOWN_ERR, "database has been closed").ptr());
+                errorCallbackProtector->handleEvent(SQLError::create(SQLError::UNKNOWN_ERR, "database has been closed"));
             });
         }
         return;
index f7dc3a1..ee4fd28 100644 (file)
@@ -39,7 +39,7 @@ class Database;
 class DatabaseCallback : public ThreadSafeRefCounted<DatabaseCallback> {
 public:
     virtual ~DatabaseCallback() { }
-    virtual bool handleEvent(Database*) = 0;
+    virtual bool handleEvent(Database&) = 0;
 };
 
 } // namespace WebCore
index deb8788..cbad34b 100644 (file)
@@ -217,7 +217,7 @@ ExceptionOr<Ref<Database>> DatabaseManager::openDatabase(ScriptExecutionContext&
         LOG(StorageAPI, "Scheduling DatabaseCreationCallbackTask for database %p\n", database.get());
         database->setHasPendingCreationEvent(true);
         database->m_scriptExecutionContext->postTask([creationCallback, database] (ScriptExecutionContext&) {
-            creationCallback->handleEvent(database.get());
+            creationCallback->handleEvent(*database);
             database->setHasPendingCreationEvent(false);
         });
     }
index ea89243..8438130 100644 (file)
@@ -213,10 +213,10 @@ bool SQLStatement::performCallback(SQLTransaction* transaction)
     // because then we need to jump to the transaction error callback.
     if (error) {
         if (errorCallback)
-            callbackError = errorCallback->handleEvent(transaction, error.get());
+            callbackError = errorCallback->handleEvent(*transaction, *error);
     } else if (callback) {
         RefPtr<SQLResultSet> resultSet = sqlResultSet();
-        callbackError = !callback->handleEvent(transaction, resultSet.get());
+        callbackError = !callback->handleEvent(*transaction, *resultSet);
     }
 
     return callbackError;
index 6da7bc4..41568cf 100644 (file)
@@ -38,7 +38,7 @@ class SQLResultSet;
 class SQLStatementCallback : public ThreadSafeRefCounted<SQLStatementCallback> {
 public:
     virtual ~SQLStatementCallback() { }
-    virtual bool handleEvent(SQLTransaction*, SQLResultSet*) = 0;
+    virtual bool handleEvent(SQLTransaction&, SQLResultSet&) = 0;
 };
 
 } // namespace WebCore
index ca5947a..013fba2 100644 (file)
@@ -38,7 +38,7 @@ class SQLError;
 class SQLStatementErrorCallback : public ThreadSafeRefCounted<SQLStatementErrorCallback> {
 public:
     virtual ~SQLStatementErrorCallback() { }
-    virtual bool handleEvent(SQLTransaction*, SQLError*) = 0;
+    virtual bool handleEvent(SQLTransaction&, SQLError&) = 0;
 };
 
 } // namespace WebCore
index 76cdd7c..7cb233f 100644 (file)
@@ -371,7 +371,7 @@ void SQLTransaction::deliverTransactionCallback()
     RefPtr<SQLTransactionCallback> callback = m_callbackWrapper.unwrap();
     if (callback) {
         m_executeSqlAllowed = true;
-        shouldDeliverErrorCallback = !callback->handleEvent(this);
+        shouldDeliverErrorCallback = !callback->handleEvent(*this);
         m_executeSqlAllowed = false;
     }
 
@@ -392,7 +392,7 @@ void SQLTransaction::deliverTransactionErrorCallback()
     // error to have occurred in this transaction.
     RefPtr<SQLTransactionErrorCallback> errorCallback = m_errorCallbackWrapper.unwrap();
     if (errorCallback)
-        errorCallback->handleEvent(m_transactionError.get());
+        errorCallback->handleEvent(*m_transactionError);
 
     clearCallbackWrappers();
 
index 52cbe69..f70287c 100644 (file)
@@ -37,7 +37,7 @@ class SQLTransaction;
 class SQLTransactionCallback : public ThreadSafeRefCounted<SQLTransactionCallback> {
 public:
     virtual ~SQLTransactionCallback() { }
-    virtual bool handleEvent(SQLTransaction*) = 0;
+    virtual bool handleEvent(SQLTransaction&) = 0;
 };
 
 } // namespace WebCore
index 89f207e..7ee8274 100644 (file)
@@ -37,7 +37,7 @@ class SQLError;
 class SQLTransactionErrorCallback : public ThreadSafeRefCounted<SQLTransactionErrorCallback> {
 public:
     virtual ~SQLTransactionErrorCallback() { }
-    virtual bool handleEvent(SQLError*) = 0;
+    virtual bool handleEvent(SQLError&) = 0;
 };
 
 } // namespace WebCore
index b5b142c..8d75766 100644 (file)
@@ -53,7 +53,9 @@ class DOMPromise;
 template<typename T>
 struct IDLType {
     using ImplementationType = T;
+
     using ParameterType = T;
+    using NullableParameterType = std::optional<ImplementationType>;
 
     using NullableType = std::optional<ImplementationType>;
     static NullableType nullValue() { return std::nullopt; }
@@ -69,6 +71,7 @@ struct IDLNull : IDLType<std::nullptr_t> { };
 
 struct IDLAny : IDLType<JSC::Strong<JSC::Unknown>> {
     using ParameterType = JSC::JSValue;
+    using NullableParameterType = JSC::JSValue;
 
     using NullableType = JSC::Strong<JSC::Unknown>;
     static inline std::nullptr_t nullValue() { return nullptr; }
@@ -106,6 +109,7 @@ struct IDLUnrestrictedDouble : IDLFloatingPoint<double> { };
 
 template<typename StringType> struct IDLString : IDLType<StringType> {
     using ParameterType = const StringType&;
+    using NullableParameterType = const StringType&;
 
     using NullableType = StringType;
     static StringType nullValue() { return StringType(); }
@@ -140,6 +144,7 @@ template<typename T> struct IDLWrapper : IDLType<RefPtr<T>> {
     using RawType = T;
 
     using ParameterType = T&;
+    using NullableParameterType = T*;
 
     using NullableType = RefPtr<T>;
     static inline std::nullptr_t nullValue() { return nullptr; }
@@ -153,6 +158,7 @@ template<typename T> struct IDLCallbackFunction : IDLWrapper<T> { };
 
 template<typename T> struct IDLDictionary : IDLType<T> {
     using ParameterType = const T&;
+    using NullableParameterType = const T&;
 };
 
 template<typename T> struct IDLEnumeration : IDLType<T> { };
@@ -160,6 +166,9 @@ template<typename T> struct IDLEnumeration : IDLType<T> { };
 template<typename T> struct IDLNullable : IDLType<typename T::NullableType> {
     using InnerType = T;
 
+    using ParameterType = typename T::NullableParameterType;
+    using NullableParameterType = typename T::NullableParameterType;
+
     using NullableType = typename T::NullableType;
     static inline auto nullValue() -> decltype(T::nullValue()) { return T::nullValue(); }
     template<typename U> static inline bool isNullValue(U&& value) { return T::isNullValue(std::forward<U>(value)); }
@@ -170,12 +179,14 @@ template<typename T> struct IDLSequence : IDLType<Vector<typename T::Implementat
     using InnerType = T;
 
     using ParameterType = const Vector<typename T::ImplementationType>&;
+    using NullableParameterType = const std::optional<Vector<typename T::ImplementationType>>&;
 };
 
 template<typename T> struct IDLFrozenArray : IDLType<Vector<typename T::ImplementationType>> {
     using InnerType = T;
 
     using ParameterType = const Vector<typename T::ImplementationType>&;
+    using NullableParameterType = const std::optional<Vector<typename T::ImplementationType>>&;
 };
 
 template<typename K, typename V> struct IDLRecord : IDLType<Vector<WTF::KeyValuePair<typename K::ImplementationType, typename V::ImplementationType>>> {
@@ -183,6 +194,7 @@ template<typename K, typename V> struct IDLRecord : IDLType<Vector<WTF::KeyValue
     using ValueType = V;
 
     using ParameterType = const Vector<WTF::KeyValuePair<typename K::ImplementationType, typename V::ImplementationType>>&;
+    using NullableParameterType = const std::optional<Vector<WTF::KeyValuePair<typename K::ImplementationType, typename V::ImplementationType>>>&;
 };
 
 template<typename T> struct IDLPromise : IDLType<DOMPromise> {
@@ -197,6 +209,7 @@ struct IDLUnion : IDLType<Variant<typename Ts::ImplementationType...>> {
     using TypeList = brigand::list<Ts...>;
 
     using ParameterType = const Variant<typename Ts::ImplementationType...>&;
+    using NullableParameterType = const std::optional<Variant<typename Ts::ImplementationType...>>&;
 };
 
 // Non-WebIDL extensions
@@ -210,6 +223,7 @@ struct IDLDate : IDLType<double> {
 
 struct IDLJSON : IDLType<String> { 
     using ParameterType = const String&;
+    using NullableParameterType = const String&;
 
     using NullableType = String;
     static String nullValue() { return String(); }
index 55bc888..141f2b7 100644 (file)
@@ -38,7 +38,7 @@ using namespace JSC;
 // FIXME: The bindings generator is currently not able to generate
 // callback function calls if they return something other than a
 // boolean.
-uint16_t JSNodeFilter::acceptNode(Node* node)
+unsigned short JSNodeFilter::acceptNode(Node& node)
 {
     Ref<JSNodeFilter> protectedThis(*this);
 
index 0030f01..4c8517f 100644 (file)
@@ -29,6 +29,7 @@
 #include "config.h"
 #include "JSSQLStatementErrorCallback.h"
 
+#include "JSDOMConvertInterface.h"
 #include "JSDOMExceptionHandling.h"
 #include "JSSQLError.h"
 #include "JSSQLTransaction.h"
@@ -41,7 +42,7 @@ namespace WebCore {
 
 using namespace JSC;
 
-bool JSSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, SQLError* error)
+bool JSSQLStatementErrorCallback::handleEvent(SQLTransaction& transaction, SQLError& error)
 {
     if (!m_data || !m_data->globalObject() || !canInvokeCallback())
         return true;
@@ -52,8 +53,8 @@ bool JSSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, SQLEr
 
     ExecState* exec = m_data->globalObject()->globalExec();
     MarkedArgumentBuffer args;
-    args.append(toJS(exec, m_data->globalObject(), transaction));
-    args.append(toJS(exec, m_data->globalObject(), error));
+    args.append(toJS<IDLInterface<SQLTransaction>>(*exec, *m_data->globalObject(), transaction));
+    args.append(toJS<IDLInterface<SQLError>>(*exec, *m_data->globalObject(), error));
 
     NakedPtr<JSC::Exception> returnedException;
     JSValue result = m_data->invokeCallback(args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
index aee0684..4aa2fb1 100644 (file)
@@ -1492,10 +1492,7 @@ sub GenerateDefaultValue
 
     if ($defaultValue eq "[]") {
         my $IDLType = GetIDLType($typeScope, $type);
-        return "Converter<${IDLType}>::ReturnType{ }" if $codeGenerator->IsSequenceOrFrozenArrayType($type);
-
-        my $nativeType = GetNativeType($typeScope, $type);
-        return "$nativeType()"
+        return "Converter<${IDLType}>::ReturnType{ }";
     }
 
     return "jsUndefined()" if $defaultValue eq "undefined";
@@ -1842,17 +1839,17 @@ sub GenerateHeader
 
     # JSValue to implementation type
     if (ShouldGenerateToWrapped($hasParent, $interface)) {
-        my $nativeType = GetNativeType($interface, $interface->type);
-
         # FIXME: Add extended attribute for this.
         my @toWrappedArguments = ();
         push(@toWrappedArguments, "JSC::VM&");
         push(@toWrappedArguments, "JSC::ExecState&") if $interface->type->name eq "XPathNSResolver";
         push(@toWrappedArguments, "JSC::JSValue");
 
+        my $toWrappedType = $interface->type->name eq "XPathNSResolver" ? "RefPtr<${implType}>" : "${implType}*";
+
         my $export = "";
         $export = "WEBCORE_EXPORT " if $interface->extendedAttributes->{ExportToWrappedFunction};
-        push(@headerContent, "    static $export$nativeType toWrapped(" . join(", ", @toWrappedArguments) . ");\n");
+        push(@headerContent, "    static ${export}${toWrappedType} toWrapped(" . join(", ", @toWrappedArguments) . ");\n");
     }
 
     $headerTrailingIncludes{"${className}Custom.h"} = 1 if $interface->extendedAttributes->{JSCustomHeader};
@@ -2271,9 +2268,11 @@ sub GenerateHeader
     }
 
     if (NeedsImplementationClass($interface)) {
+        my $toWrappedType = $interface->type->name eq "XPathNSResolver" ? "RefPtr<${implType}>" : "${implType}*";
+    
         push(@headerContent, "template<> struct JSDOMWrapperConverterTraits<${implType}> {\n");
         push(@headerContent, "    using WrapperClass = ${className};\n");
-        push(@headerContent, "    using ToWrappedReturnType = " . GetNativeType($interface, $interface->type) . ";\n");
+        push(@headerContent, "    using ToWrappedReturnType = ${toWrappedType};\n");
         push(@headerContent, "};\n");
     }
 
@@ -4257,22 +4256,12 @@ END
                     my $type = $argument->type;
                     my $name = $argument->name;
                     my $encodedName = "encoded" . $codeGenerator->WK_ucfirst($name);
-                    my $nativeType = GetNativeType($interface, $argument->type);
                     my $shouldPassByReference = ShouldPassArgumentByReference($argument);
 
-                    if (!$shouldPassByReference && ($codeGenerator->IsWrapperType($type) || $codeGenerator->IsTypedArrayType($type))) {
-                        $implIncludes{"<runtime/Error.h>"} = 1;
-                        my ($nativeValue, $mayThrowException) = UnsafeToNative($interface, $argument, $encodedName, $function->extendedAttributes->{Conditional});
-                        push(@implContent, "    $nativeType $name = nullptr;\n");
-                        push(@implContent, "    $name = $nativeValue;\n");
-                        push(@implContent, "    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());\n") if $mayThrowException;
-                        $value = "WTFMove($name)";
-                    } else {
-                        my ($nativeValue, $mayThrowException) = UnsafeToNative($interface, $argument, $encodedName, $function->extendedAttributes->{Conditional});
-                        push(@implContent, "    auto $name = ${nativeValue};\n");
-                        $value = "WTFMove($name)";
-                        push(@implContent, "    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());\n") if $mayThrowException;
-                    }
+                    my ($nativeValue, $mayThrowException) = UnsafeToNative($interface, $argument, $encodedName, $function->extendedAttributes->{Conditional});
+                    push(@implContent, "    auto $name = ${nativeValue};\n");
+                    push(@implContent, "    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());\n") if $mayThrowException;
+                    $value = "WTFMove($name)";
 
                     if ($shouldPassByReference) {
                         $value = "*$name";
@@ -4947,41 +4936,40 @@ sub GenerateParametersCheck
 
             push(@$outputArray, "    }\n") if $indent ne "";
         } else {
-            my $outer;
-            my $inner;
-            my $nativeType = GetNativeType($interface, $argument->type);
-
-            die "Variadic argument is already handled here" if $argument->isVariadic;
-            my $argumentLookupMethod = $argument->isOptional ? "argument" : "uncheckedArgument";
+            my $argumentLookupForConversion;
+            my $optionalCheck;
             my $nativeValueCastFunction;
 
-            if ($argument->isOptional && defined($argument->default) && !WillConvertUndefinedToDefaultParameterValue($type, $argument->default)) {
-                my $defaultValue = $argument->default;
-
-                $defaultValue = GenerateDefaultValue($interface, $argument, $argument->type, $argument->default);
+            if ($argument->isOptional) {
+                if (defined($argument->default)) {
+                    if (WillConvertUndefinedToDefaultParameterValue($type, $argument->default)) {
+                        $argumentLookupForConversion = "state->argument($argumentIndex)";
+                    } else {
+                        my $defaultValue = GenerateDefaultValue($interface, $argument, $argument->type, $argument->default);
+                        $optionalCheck = "state->argument($argumentIndex).isUndefined() ? $defaultValue : ";
+                        $argumentLookupForConversion = "state->uncheckedArgument($argumentIndex)"
+                    }
+                } else {
+                    my $argumentIDLType = GetIDLType($interface, $argument->type);
+                    my $defaultValue = "std::optional<Converter<$argumentIDLType>::ReturnType>()";
 
-                $outer = "state->$argumentLookupMethod($argumentIndex).isUndefined() ? $defaultValue : ";
-                $inner = "state->uncheckedArgument($argumentIndex)";
-            } elsif ($argument->isOptional && !defined($argument->default)) {
-                # Use std::optional<>() for optional arguments that are missing or undefined and that do not have a default value in the IDL.
-                $outer = "state->$argumentLookupMethod($argumentIndex).isUndefined() ? std::optional<$nativeType>() : ";
-                $nativeValueCastFunction = "std::optional<$nativeType>";
-                $inner = "state->uncheckedArgument($argumentIndex)";
+                    $optionalCheck = "state->argument($argumentIndex).isUndefined() ? $defaultValue : ";
+                    $argumentLookupForConversion = "state->uncheckedArgument($argumentIndex)";
+                    $nativeValueCastFunction = "std::optional<Converter<$argumentIDLType>::ReturnType>";
+                }
             } else {
-                $outer = "";
-                $inner = "state->$argumentLookupMethod($argumentIndex)";
+                $argumentLookupForConversion = "state->uncheckedArgument($argumentIndex)";
             }
-
+    
             my $globalObjectReference = $function->isStatic ? "*jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())" : "*castedThis->globalObject()";
             my $argumentExceptionThrower = GetArgumentExceptionThrower($interface, $argument, $argumentIndex, $quotedFunctionName);
 
-            my ($nativeValue, $mayThrowException) = JSValueToNative($interface, $argument, $inner, $conditional, "state", "*state", "*castedThis", $globalObjectReference, $argumentExceptionThrower);
+            my ($nativeValue, $mayThrowException) = JSValueToNative($interface, $argument, $argumentLookupForConversion, $conditional, "state", "*state", "*castedThis", $globalObjectReference, $argumentExceptionThrower);
 
-            if (defined $nativeValueCastFunction) {
-                push(@$outputArray, "    auto $name = ${outer}$nativeValueCastFunction(${nativeValue});\n");
-            } else {
-                push(@$outputArray, "    auto $name = ${outer}${nativeValue};\n");
-            }
+            $nativeValue = "${nativeValueCastFunction}(" . $nativeValue . ")" if defined $nativeValueCastFunction;
+            $nativeValue = $optionalCheck . $nativeValue if defined $optionalCheck;
+
+            push(@$outputArray, "    auto $name = ${nativeValue};\n");
             push(@$outputArray, "    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());\n") if $mayThrowException;
 
             $value = PassArgumentExpression($name, $argument);
@@ -5146,11 +5134,12 @@ sub GenerateCallbackHeaderContent
     my $className = "JS${name}";
 
     $includesRef->{"ActiveDOMCallback.h"} = 1;
+    $includesRef->{"IDLTypes.h"} = 1;
     $includesRef->{"JSCallbackData.h"} = 1;
     $includesRef->{"<wtf/Forward.h>"} = 1;
     $includesRef->{"${name}.h"} = 1;
 
-    push(@$contentRef, "class $className : public ${name}, public ActiveDOMCallback {\n");
+    push(@$contentRef, "class $className final : public ${name}, public ActiveDOMCallback {\n");
     push(@$contentRef, "public:\n");
 
     # The static create() method.
@@ -5167,7 +5156,7 @@ sub GenerateCallbackHeaderContent
 
     push(@$contentRef, "    static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);\n") if @{$constants};
 
-    push(@$contentRef, "    virtual bool operator==(const ${name}&) const;\n\n") if $interfaceOrCallback->extendedAttributes->{CallbackNeedsOperatorEqual};
+    push(@$contentRef, "    virtual bool operator==(const ${name}&) const override;\n\n") if $interfaceOrCallback->extendedAttributes->{CallbackNeedsOperatorEqual};
 
     # Functions
     my $numFunctions = @{$functions};
@@ -5176,16 +5165,17 @@ sub GenerateCallbackHeaderContent
         foreach my $function (@{$functions}) {
             my @arguments = ();
             foreach my $argument (@{$function->arguments}) {
-                push(@arguments, GetNativeTypeForCallbacks($argument->type, $interfaceOrCallback) . " " . $argument->name);
+                my $IDLType = GetIDLType($interfaceOrCallback, $argument->type);
+                push(@arguments, "typename ${IDLType}::ParameterType " . $argument->name);
             }
 
             # FIXME: Add support for non-void return types (the bool actually is returning exception state), for non-custom functions.
-            my $nativeReturnType = $function->extendedAttributes->{Custom} ? GetNativeTypeForCallbacks($function->type, $interfaceOrCallback) : "bool";
+            my $nativeReturnType = $function->extendedAttributes->{Custom} ? "typename " . GetIDLType($interfaceOrCallback, $function->type) . "::ImplementationType" : "bool";
             
             # FIXME: Change the default name (used for callback functions) to something other than handleEvent. It makes little sense.
             my $functionName = $function->name ? $function->name : "handleEvent";
 
-            push(@$contentRef, "    virtual ${nativeReturnType} ${functionName}(" . join(", ", @arguments) . ");\n");
+            push(@$contentRef, "    virtual ${nativeReturnType} ${functionName}(" . join(", ", @arguments) . ") override;\n");
         }
     }
 
@@ -5305,12 +5295,18 @@ sub GenerateCallbackImplementationContent
             # FIXME: Change the default name (used for callback functions) to something other than handleEvent. It makes little sense.
             my $functionName = $function->name ? $function->name : "handleEvent";
 
+            # FIXME: Add support for non-void return types (the bool actually is returning exception state), for non-custom functions.
+            my $nativeReturnType = "bool";
+
             my @args = ();
             foreach my $argument (@{$function->arguments}) {
                 AddToIncludesForIDLType($argument->type, $includesRef, 1);
-                push(@args, GetNativeTypeForCallbacks($argument->type, $interfaceOrCallback) . " " . $argument->name);
+
+                my $IDLType = GetIDLType($interfaceOrCallback, $argument->type);
+                push(@args, "typename ${IDLType}::ParameterType " . $argument->name);
             }
-            push(@$contentRef, "bool ${className}::${functionName}(" . join(", ", @args) . ")\n");
+            
+            push(@$contentRef, "${nativeReturnType} ${className}::${functionName}(" . join(", ", @args) . ")\n");
             push(@$contentRef, "{\n");
             push(@$contentRef, "    if (!canInvokeCallback())\n");
             push(@$contentRef, "        return true;\n\n");
@@ -5457,31 +5453,6 @@ END
     }
 }
 
-my %nativeType = (
-    "ByteString" => "String",
-    "DOMString" => "String",
-    "USVString" => "String",
-    "Date" => "double",
-    "EventListener" => "RefPtr<EventListener>",
-    "SerializedScriptValue" => "RefPtr<SerializedScriptValue>",
-    "XPathNSResolver" => "RefPtr<XPathNSResolver>",
-    "any" => "JSC::JSValue",
-    "object" => "JSC::Strong<JSC::JSObject>",
-    "boolean" => "bool",
-    "byte" => "int8_t",
-    "double" => "double",
-    "float" => "float",
-    "long long" => "int64_t",
-    "long" => "int32_t",
-    "octet" => "uint8_t",
-    "short" => "int16_t",
-    "unrestricted double" => "double",
-    "unrestricted float" => "float",
-    "unsigned long long" => "uint64_t",
-    "unsigned long" => "uint32_t",
-    "unsigned short" => "uint16_t",
-);
-
 # http://heycam.github.io/webidl/#dfn-flattened-union-member-types
 sub GetFlattenedMemberTypes
 {
@@ -5627,54 +5598,6 @@ sub GetIDLType
     return $baseIDLType;
 }
 
-sub GetNativeType
-{
-    my ($interface, $type) = @_;
-
-    assert("Not a type") if ref($type) ne "IDLType";
-
-    my $typeName = $type->name;
-
-    return $nativeType{$typeName} if exists $nativeType{$typeName};
-
-    return GetEnumerationClassName($type, $interface) if $codeGenerator->IsEnumType($type);
-    return GetDictionaryClassName($type, $interface) if $codeGenerator->IsDictionaryType($type);
-    return "Vector<" . GetNativeInnerType(@{$type->subtypes}[0], $interface) . ">" if $codeGenerator->IsSequenceOrFrozenArrayType($type);
-    return "Vector<WTF::KeyValuePair<" . GetNativeInnerType(@{$type->subtypes}[0], $interface) . ", " . GetNativeInnerType(@{$type->subtypes}[1], $interface) . ">>" if $codeGenerator->IsRecordType($type);
-
-    if ($type->isUnion) {
-        my $IDLType = GetIDLType($interface, $type);
-        return "Converter<$IDLType>::ReturnType";
-    }
-    
-    return "RefPtr<${typeName}>" if $codeGenerator->IsTypedArrayType($type) and $typeName ne "ArrayBuffer";
-    return "${typeName}*";
-}
-
-sub GetNativeInnerType
-{
-    my ($innerType, $interface) = @_;
-
-    my $innerTypeName = $innerType->name;
-
-    return $nativeType{$innerTypeName} if exists $nativeType{$innerTypeName};
-
-    return GetEnumerationClassName($innerType, $interface) if $codeGenerator->IsEnumType($innerType);
-    return GetDictionaryClassName($innerType, $interface) if $codeGenerator->IsDictionaryType($innerType);
-    return "Vector<" . GetNativeInnerType(@{$innerType->subtypes}[0], $interface) . ">" if $codeGenerator->IsSequenceOrFrozenArrayType($innerType);
-    return "Vector<WTF::KeyValuePair<" . GetNativeInnerType(@{$innerType->subtypes}[0], $interface) . ", " . GetNativeInnerType(@{$innerType->subtypes}[1], $interface) . ">>" if $codeGenerator->IsRecordType($innerType);
-    return "RefPtr<$innerTypeName>";
-}
-
-sub GetNativeTypeForCallbacks
-{
-    my ($type, $interface) = @_;
-
-    return "RefPtr<SerializedScriptValue>&&" if $type->name eq "SerializedScriptValue";
-    return "const String&" if $codeGenerator->IsStringType($type);
-    return GetNativeType($interface, $type);
-}
-
 sub ShouldPassArgumentByReference
 {
     my ($argument) = @_;
index 1ea108f..822675e 100644 (file)
@@ -56,7 +56,7 @@ JSTestCallbackFunction::~JSTestCallbackFunction()
 #endif
 }
 
-bool JSTestCallbackFunction::handleEvent(RefPtr<Float32Array> arrayParam, RefPtr<SerializedScriptValue>&& srzParam, const String& strArg, bool boolParam, int32_t longParam, TestNode* testNodeParam)
+bool JSTestCallbackFunction::handleEvent(typename IDLInterface<Float32Array>::ParameterType arrayParam, typename IDLSerializedScriptValue<SerializedScriptValue>::ParameterType srzParam, typename IDLDOMString::ParameterType strArg, typename IDLBoolean::ParameterType boolParam, typename IDLLong::ParameterType longParam, typename IDLInterface<TestNode>::ParameterType testNodeParam)
 {
     if (!canInvokeCallback())
         return true;
index b945dd0..7975f5b 100644 (file)
 #if ENABLE(SPEECH_SYNTHESIS)
 
 #include "ActiveDOMCallback.h"
+#include "IDLTypes.h"
 #include "JSCallbackData.h"
 #include "TestCallbackFunction.h"
 #include <wtf/Forward.h>
 
 namespace WebCore {
 
-class JSTestCallbackFunction : public TestCallbackFunction, public ActiveDOMCallback {
+class JSTestCallbackFunction final : public TestCallbackFunction, public ActiveDOMCallback {
 public:
     static Ref<JSTestCallbackFunction> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)
     {
@@ -42,7 +43,7 @@ public:
     JSCallbackDataStrong* callbackData() { return m_data; }
 
     // Functions
-    virtual bool handleEvent(RefPtr<Float32Array> arrayParam, RefPtr<SerializedScriptValue>&& srzParam, const String& strArg, bool boolParam, int32_t longParam, TestNode* testNodeParam);
+    virtual bool handleEvent(typename IDLInterface<Float32Array>::ParameterType arrayParam, typename IDLSerializedScriptValue<SerializedScriptValue>::ParameterType srzParam, typename IDLDOMString::ParameterType strArg, typename IDLBoolean::ParameterType boolParam, typename IDLLong::ParameterType longParam, typename IDLInterface<TestNode>::ParameterType testNodeParam) override;
 
 private:
     JSTestCallbackFunction(JSC::JSObject*, JSDOMGlobalObject*);
index a89ac0d..3740d7a 100644 (file)
@@ -52,7 +52,7 @@ JSTestCallbackFunctionWithTypedefs::~JSTestCallbackFunctionWithTypedefs()
 #endif
 }
 
-bool JSTestCallbackFunctionWithTypedefs::handleEvent(Vector<int32_t> sequenceArg, int32_t longArg)
+bool JSTestCallbackFunctionWithTypedefs::handleEvent(typename IDLSequence<IDLNullable<IDLLong>>::ParameterType sequenceArg, typename IDLLong::ParameterType longArg)
 {
     if (!canInvokeCallback())
         return true;
index 1086584..2452929 100644 (file)
 #pragma once
 
 #include "ActiveDOMCallback.h"
+#include "IDLTypes.h"
 #include "JSCallbackData.h"
 #include "TestCallbackFunctionWithTypedefs.h"
 #include <wtf/Forward.h>
 
 namespace WebCore {
 
-class JSTestCallbackFunctionWithTypedefs : public TestCallbackFunctionWithTypedefs, public ActiveDOMCallback {
+class JSTestCallbackFunctionWithTypedefs final : public TestCallbackFunctionWithTypedefs, public ActiveDOMCallback {
 public:
     static Ref<JSTestCallbackFunctionWithTypedefs> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)
     {
@@ -40,7 +41,7 @@ public:
     JSCallbackDataStrong* callbackData() { return m_data; }
 
     // Functions
-    virtual bool handleEvent(Vector<int32_t> sequenceArg, int32_t longArg);
+    virtual bool handleEvent(typename IDLSequence<IDLNullable<IDLLong>>::ParameterType sequenceArg, typename IDLLong::ParameterType longArg) override;
 
 private:
     JSTestCallbackFunctionWithTypedefs(JSC::JSObject*, JSDOMGlobalObject*);
index 9dfd2dd..b0c0188 100644 (file)
@@ -112,7 +112,7 @@ bool JSTestCallbackInterface::callbackWithNoParam()
     return !returnedException;
 }
 
-bool JSTestCallbackInterface::callbackWithArrayParam(RefPtr<Float32Array> arrayParam)
+bool JSTestCallbackInterface::callbackWithArrayParam(typename IDLInterface<Float32Array>::ParameterType arrayParam)
 {
     if (!canInvokeCallback())
         return true;
@@ -132,7 +132,7 @@ bool JSTestCallbackInterface::callbackWithArrayParam(RefPtr<Float32Array> arrayP
     return !returnedException;
 }
 
-bool JSTestCallbackInterface::callbackWithSerializedScriptValueParam(RefPtr<SerializedScriptValue>&& srzParam, const String& strParam)
+bool JSTestCallbackInterface::callbackWithSerializedScriptValueParam(typename IDLSerializedScriptValue<SerializedScriptValue>::ParameterType srzParam, typename IDLDOMString::ParameterType strParam)
 {
     if (!canInvokeCallback())
         return true;
@@ -153,7 +153,7 @@ bool JSTestCallbackInterface::callbackWithSerializedScriptValueParam(RefPtr<Seri
     return !returnedException;
 }
 
-bool JSTestCallbackInterface::callbackWithStringList(DOMStringList* listParam)
+bool JSTestCallbackInterface::callbackWithStringList(typename IDLInterface<DOMStringList>::ParameterType listParam)
 {
     if (!canInvokeCallback())
         return true;
@@ -173,7 +173,7 @@ bool JSTestCallbackInterface::callbackWithStringList(DOMStringList* listParam)
     return !returnedException;
 }
 
-bool JSTestCallbackInterface::callbackWithBoolean(bool boolParam)
+bool JSTestCallbackInterface::callbackWithBoolean(typename IDLBoolean::ParameterType boolParam)
 {
     if (!canInvokeCallback())
         return true;
@@ -193,7 +193,7 @@ bool JSTestCallbackInterface::callbackWithBoolean(bool boolParam)
     return !returnedException;
 }
 
-bool JSTestCallbackInterface::callbackRequiresThisToPass(int32_t longParam, TestNode* testNodeParam)
+bool JSTestCallbackInterface::callbackRequiresThisToPass(typename IDLLong::ParameterType longParam, typename IDLInterface<TestNode>::ParameterType testNodeParam)
 {
     if (!canInvokeCallback())
         return true;
index 6c0164e..6922006 100644 (file)
 #if ENABLE(SPEECH_SYNTHESIS)
 
 #include "ActiveDOMCallback.h"
+#include "IDLTypes.h"
 #include "JSCallbackData.h"
 #include "TestCallbackInterface.h"
 #include <wtf/Forward.h>
 
 namespace WebCore {
 
-class JSTestCallbackInterface : public TestCallbackInterface, public ActiveDOMCallback {
+class JSTestCallbackInterface final : public TestCallbackInterface, public ActiveDOMCallback {
 public:
     static Ref<JSTestCallbackInterface> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)
     {
@@ -43,13 +44,13 @@ public:
     static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);
 
     // Functions
-    virtual bool callbackWithNoParam();
-    virtual bool callbackWithArrayParam(RefPtr<Float32Array> arrayParam);
-    virtual bool callbackWithSerializedScriptValueParam(RefPtr<SerializedScriptValue>&& srzParam, const String& strParam);
-    virtual int32_t customCallback(Class5* class5Param, Class6* class6Param);
-    virtual bool callbackWithStringList(DOMStringList* listParam);
-    virtual bool callbackWithBoolean(bool boolParam);
-    virtual bool callbackRequiresThisToPass(int32_t longParam, TestNode* testNodeParam);
+    virtual bool callbackWithNoParam() override;
+    virtual bool callbackWithArrayParam(typename IDLInterface<Float32Array>::ParameterType arrayParam) override;
+    virtual bool callbackWithSerializedScriptValueParam(typename IDLSerializedScriptValue<SerializedScriptValue>::ParameterType srzParam, typename IDLDOMString::ParameterType strParam) override;
+    virtual typename IDLLong::ImplementationType customCallback(typename IDLInterface<TestObj>::ParameterType testObjParam, typename IDLInterface<TestNode>::ParameterType testNodeParam) override;
+    virtual bool callbackWithStringList(typename IDLInterface<DOMStringList>::ParameterType listParam) override;
+    virtual bool callbackWithBoolean(typename IDLBoolean::ParameterType boolParam) override;
+    virtual bool callbackRequiresThisToPass(typename IDLLong::ParameterType longParam, typename IDLInterface<TestNode>::ParameterType testNodeParam) override;
 
 private:
     JSTestCallbackInterface(JSC::JSObject*, JSDOMGlobalObject*);
index 6e69da4..07d924d 100644 (file)
@@ -6368,7 +6368,7 @@ static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithOptionalAr
     UNUSED_PARAM(state);
     UNUSED_PARAM(throwScope);
     auto& impl = castedThis->wrapped();
-    auto opt = state->argument(0).isUndefined() ? std::optional<int32_t>() : std::optional<int32_t>(convert<IDLLong>(*state, state->uncheckedArgument(0)));
+    auto opt = state->argument(0).isUndefined() ? std::optional<Converter<IDLLong>::ReturnType>() : std::optional<Converter<IDLLong>::ReturnType>(convert<IDLLong>(*state, state->uncheckedArgument(0)));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     impl.methodWithOptionalArg(WTFMove(opt));
     return JSValue::encode(jsUndefined());
@@ -6408,7 +6408,7 @@ static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithNonOptiona
         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
     auto nonOpt = convert<IDLLong>(*state, state->uncheckedArgument(0));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
-    auto opt = state->argument(1).isUndefined() ? std::optional<int32_t>() : std::optional<int32_t>(convert<IDLLong>(*state, state->uncheckedArgument(1)));
+    auto opt = state->argument(1).isUndefined() ? std::optional<Converter<IDLLong>::ReturnType>() : std::optional<Converter<IDLLong>::ReturnType>(convert<IDLLong>(*state, state->uncheckedArgument(1)));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     impl.methodWithNonOptionalArgAndOptionalArg(WTFMove(nonOpt), WTFMove(opt));
     return JSValue::encode(jsUndefined());
@@ -6430,9 +6430,9 @@ static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithNonOptiona
         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
     auto nonOpt = convert<IDLLong>(*state, state->uncheckedArgument(0));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
-    auto opt1 = state->argument(1).isUndefined() ? std::optional<int32_t>() : std::optional<int32_t>(convert<IDLLong>(*state, state->uncheckedArgument(1)));
+    auto opt1 = state->argument(1).isUndefined() ? std::optional<Converter<IDLLong>::ReturnType>() : std::optional<Converter<IDLLong>::ReturnType>(convert<IDLLong>(*state, state->uncheckedArgument(1)));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
-    auto opt2 = state->argument(2).isUndefined() ? std::optional<int32_t>() : std::optional<int32_t>(convert<IDLLong>(*state, state->uncheckedArgument(2)));
+    auto opt2 = state->argument(2).isUndefined() ? std::optional<Converter<IDLLong>::ReturnType>() : std::optional<Converter<IDLLong>::ReturnType>(convert<IDLLong>(*state, state->uncheckedArgument(2)));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     impl.methodWithNonOptionalArgAndTwoOptionalArgs(WTFMove(nonOpt), WTFMove(opt1), WTFMove(opt2));
     return JSValue::encode(jsUndefined());
@@ -6684,7 +6684,7 @@ static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithOptionalLo
     UNUSED_PARAM(state);
     UNUSED_PARAM(throwScope);
     auto& impl = castedThis->wrapped();
-    auto number = state->argument(0).isUndefined() ? std::optional<int64_t>() : std::optional<int64_t>(convert<IDLLongLong>(*state, state->uncheckedArgument(0)));
+    auto number = state->argument(0).isUndefined() ? std::optional<Converter<IDLLongLong>::ReturnType>() : std::optional<Converter<IDLLongLong>::ReturnType>(convert<IDLLongLong>(*state, state->uncheckedArgument(0)));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     impl.methodWithOptionalLongLong(WTFMove(number));
     return JSValue::encode(jsUndefined());
@@ -6720,7 +6720,7 @@ static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithOptionalUn
     UNUSED_PARAM(state);
     UNUSED_PARAM(throwScope);
     auto& impl = castedThis->wrapped();
-    auto number = state->argument(0).isUndefined() ? std::optional<uint64_t>() : std::optional<uint64_t>(convert<IDLUnsignedLongLong>(*state, state->uncheckedArgument(0)));
+    auto number = state->argument(0).isUndefined() ? std::optional<Converter<IDLUnsignedLongLong>::ReturnType>() : std::optional<Converter<IDLUnsignedLongLong>::ReturnType>(convert<IDLUnsignedLongLong>(*state, state->uncheckedArgument(0)));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     impl.methodWithOptionalUnsignedLongLong(WTFMove(number));
     return JSValue::encode(jsUndefined());
@@ -6792,7 +6792,7 @@ static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithOptionalBo
     UNUSED_PARAM(state);
     UNUSED_PARAM(throwScope);
     auto& impl = castedThis->wrapped();
-    auto b = state->argument(0).isUndefined() ? std::optional<bool>() : std::optional<bool>(convert<IDLBoolean>(*state, state->uncheckedArgument(0)));
+    auto b = state->argument(0).isUndefined() ? std::optional<Converter<IDLBoolean>::ReturnType>() : std::optional<Converter<IDLBoolean>::ReturnType>(convert<IDLBoolean>(*state, state->uncheckedArgument(0)));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     impl.methodWithOptionalBoolean(WTFMove(b));
     return JSValue::encode(jsUndefined());
@@ -6846,7 +6846,7 @@ static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithOptionalOb
     UNUSED_PARAM(state);
     UNUSED_PARAM(throwScope);
     auto& impl = castedThis->wrapped();
-    auto a = state->argument(0).isUndefined() ? std::optional<JSC::Strong<JSC::JSObject>>() : std::optional<JSC::Strong<JSC::JSObject>>(convert<IDLObject>(*state, state->uncheckedArgument(0)));
+    auto a = state->argument(0).isUndefined() ? std::optional<Converter<IDLObject>::ReturnType>() : std::optional<Converter<IDLObject>::ReturnType>(convert<IDLObject>(*state, state->uncheckedArgument(0)));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     impl.methodWithOptionalObject(WTFMove(a));
     return JSValue::encode(jsUndefined());
@@ -7162,7 +7162,7 @@ static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionOverloadedMethod2Cal
         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
     auto objArg = convert<IDLNullable<IDLInterface<TestObj>>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "objArg", "TestObject", "overloadedMethod", "TestObj"); });
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
-    auto longArg = state->argument(1).isUndefined() ? std::optional<int32_t>() : std::optional<int32_t>(convert<IDLLong>(*state, state->uncheckedArgument(1)));
+    auto longArg = state->argument(1).isUndefined() ? std::optional<Converter<IDLLong>::ReturnType>() : std::optional<Converter<IDLLong>::ReturnType>(convert<IDLLong>(*state, state->uncheckedArgument(1)));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     impl.overloadedMethod(WTFMove(objArg), WTFMove(longArg));
     return JSValue::encode(jsUndefined());
@@ -7470,7 +7470,7 @@ static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionOverloadedMethodWith
         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
     auto objArg = convert<IDLNullable<IDLInterface<TestObj>>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "objArg", "TestObject", "overloadedMethodWithOptionalParameter", "TestObj"); });
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
-    auto longArg = state->argument(1).isUndefined() ? std::optional<int32_t>() : std::optional<int32_t>(convert<IDLLong>(*state, state->uncheckedArgument(1)));
+    auto longArg = state->argument(1).isUndefined() ? std::optional<Converter<IDLLong>::ReturnType>() : std::optional<Converter<IDLLong>::ReturnType>(convert<IDLLong>(*state, state->uncheckedArgument(1)));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     impl.overloadedMethodWithOptionalParameter(WTFMove(objArg), WTFMove(longArg));
     return JSValue::encode(jsUndefined());
@@ -7877,7 +7877,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionClassMethodWithOptional
     VM& vm = state->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
     UNUSED_PARAM(throwScope);
-    auto arg = state->argument(0).isUndefined() ? std::optional<int32_t>() : std::optional<int32_t>(convert<IDLLong>(*state, state->uncheckedArgument(0)));
+    auto arg = state->argument(0).isUndefined() ? std::optional<Converter<IDLLong>::ReturnType>() : std::optional<Converter<IDLLong>::ReturnType>(convert<IDLLong>(*state, state->uncheckedArgument(0)));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     return JSValue::encode(toJS<IDLLong>(TestObj::classMethodWithOptional(WTFMove(arg))));
 }
@@ -8471,7 +8471,7 @@ static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionW
     UNUSED_PARAM(state);
     UNUSED_PARAM(throwScope);
     auto& impl = castedThis->wrapped();
-    auto a = state->argument(0).isUndefined() ? std::optional<int32_t>() : std::optional<int32_t>(convert<IDLLong>(*state, state->uncheckedArgument(0)));
+    auto a = state->argument(0).isUndefined() ? std::optional<Converter<IDLLong>::ReturnType>() : std::optional<Converter<IDLLong>::ReturnType>(convert<IDLLong>(*state, state->uncheckedArgument(0)));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     impl.testPromiseFunctionWithOptionalIntArgument(WTFMove(a), WTFMove(promise));
     return JSValue::encode(jsUndefined());
index 6fcd126..354defa 100644 (file)
@@ -607,7 +607,7 @@ static inline JSC::EncodedJSValue jsTestTypedefsPrototypeFunctionSetShadowCaller
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     auto color = state->argument(3).isUndefined() ? String() : convert<IDLDOMString>(*state, state->uncheckedArgument(3));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
-    auto alpha = state->argument(4).isUndefined() ? std::optional<float>() : std::optional<float>(convert<IDLUnrestrictedFloat>(*state, state->uncheckedArgument(4)));
+    auto alpha = state->argument(4).isUndefined() ? std::optional<Converter<IDLUnrestrictedFloat>::ReturnType>() : std::optional<Converter<IDLUnrestrictedFloat>::ReturnType>(convert<IDLUnrestrictedFloat>(*state, state->uncheckedArgument(4)));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     impl.setShadow(WTFMove(width), WTFMove(height), WTFMove(blur), WTFMove(color), WTFMove(alpha));
     return JSValue::encode(jsUndefined());
@@ -748,7 +748,7 @@ static inline JSC::EncodedJSValue jsTestTypedefsPrototypeFunctionFuncWithClampCa
         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
     auto arg1 = convert<IDLClampAdaptor<IDLUnsignedLongLong>>(*state, state->uncheckedArgument(0));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
-    auto arg2 = state->argument(1).isUndefined() ? std::optional<uint64_t>() : std::optional<uint64_t>(convert<IDLClampAdaptor<IDLUnsignedLongLong>>(*state, state->uncheckedArgument(1)));
+    auto arg2 = state->argument(1).isUndefined() ? std::optional<Converter<IDLClampAdaptor<IDLUnsignedLongLong>>::ReturnType>() : std::optional<Converter<IDLClampAdaptor<IDLUnsignedLongLong>>::ReturnType>(convert<IDLClampAdaptor<IDLUnsignedLongLong>>(*state, state->uncheckedArgument(1)));
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     impl.funcWithClamp(WTFMove(arg1), WTFMove(arg2));
     return JSValue::encode(jsUndefined());
index dc3b87f..c95d4eb 100644 (file)
@@ -37,7 +37,7 @@
     void callbackWithNoParam();
     void callbackWithArrayParam(Float32Array arrayParam);
     void callbackWithSerializedScriptValueParam(SerializedScriptValue srzParam, DOMString strParam);
-    [Custom] long customCallback(Class5 class5Param, Class6 class6Param);
+    [Custom] long customCallback(TestObj testObjParam, TestNode testNodeParam);
     void callbackWithStringList(DOMStringList listParam);
     void callbackWithBoolean(boolean boolParam);
     void callbackRequiresThisToPass(long longParam, TestNode testNodeParam);
index 4def1fd..e7a7626 100644 (file)
@@ -31,7 +31,7 @@ public:
         JSMediaQueryListListenerType
     };
 
-    virtual bool handleEvent(MediaQueryList*) = 0;
+    virtual bool handleEvent(MediaQueryList&) = 0;
     virtual bool operator==(const MediaQueryListListener&) const = 0;
     virtual ~MediaQueryListListener() { }
 
index 5b6b027..fdf1db7 100644 (file)
@@ -19,5 +19,5 @@
 
 [
     CallbackNeedsOperatorEqual
-] callback MediaQueryListListener = void (optional MediaQueryList? list = null);
+] callback MediaQueryListListener = void (MediaQueryList list);
 
index d1a30d3..ce01264 100644 (file)
@@ -127,7 +127,7 @@ void MediaQueryMatcher::styleResolverChanged()
         bool notify;
         listener.query->evaluate(evaluator, notify);
         if (notify)
-            listener.listener->handleEvent(listener.query.ptr());
+            listener.listener->handleEvent(listener.query);
     }
 }
 
index a0a34c9..efd3e6e 100644 (file)
@@ -30,12 +30,13 @@ namespace WebCore {
 
 NativeNodeFilter::NativeNodeFilter(RefPtr<NodeFilterCondition>&& condition)
     : m_condition(condition)
-{ }
+{
+}
 
-uint16_t NativeNodeFilter::acceptNode(Node* node)
+unsigned short NativeNodeFilter::acceptNode(Node& node)
 {
     // cast to short silences "enumeral and non-enumeral types in return" warning
-    return m_condition ? m_condition->acceptNode(node) : static_cast<uint16_t>(FILTER_ACCEPT);
+    return m_condition ? m_condition->acceptNode(&node) : static_cast<unsigned short>(FILTER_ACCEPT);
 }
 
 } // namespace WebCore
index 983b5f4..b132832 100644 (file)
@@ -43,7 +43,7 @@ public:
         return adoptRef(*new NativeNodeFilter());
     }
 
-    uint16_t acceptNode(Node*) override;
+    unsigned short acceptNode(Node&) override;
 
     void setCondition(RefPtr<NodeFilterCondition>&& condition) { ASSERT(!m_condition); m_condition = condition; }
 
index 04372a1..add08f2 100644 (file)
@@ -33,7 +33,7 @@ class Node;
 class NodeFilter : public RefCounted<NodeFilter> {
 public:
     virtual ~NodeFilter() { }
-    virtual uint16_t acceptNode(Node*) = 0;
+    virtual unsigned short acceptNode(Node&) = 0;
 
     /*
      * The following constants are returned by the acceptNode()
index cf232cc..9f5e373 100644 (file)
@@ -41,5 +41,5 @@
     const unsigned long SHOW_DOCUMENT_FRAGMENT = 0x00000400;
     const unsigned long SHOW_NOTATION = 0x00000800; // Historical.
 
-    [Custom] unsigned short acceptNode(optional Node node);
+    [Custom] unsigned short acceptNode(Node node);
 };
index cd6957a..9108ea5 100644 (file)
@@ -97,7 +97,7 @@ RefPtr<Node> NodeIterator::nextNode()
         // In other words, FILTER_REJECT does not pass over descendants
         // of the rejected node. Hence, FILTER_REJECT is the same as FILTER_SKIP.
         RefPtr<Node> provisionalResult = m_candidateNode.node;
-        bool nodeWasAccepted = acceptNode(provisionalResult.get()) == NodeFilter::FILTER_ACCEPT;
+        bool nodeWasAccepted = acceptNode(*provisionalResult) == NodeFilter::FILTER_ACCEPT;
         if (nodeWasAccepted) {
             m_referenceNode = m_candidateNode;
             result = WTFMove(provisionalResult);
@@ -119,7 +119,7 @@ RefPtr<Node> NodeIterator::previousNode()
         // In other words, FILTER_REJECT does not pass over descendants
         // of the rejected node. Hence, FILTER_REJECT is the same as FILTER_SKIP.
         RefPtr<Node> provisionalResult = m_candidateNode.node;
-        bool nodeWasAccepted = acceptNode(provisionalResult.get()) == NodeFilter::FILTER_ACCEPT;
+        bool nodeWasAccepted = acceptNode(*provisionalResult) == NodeFilter::FILTER_ACCEPT;
         if (nodeWasAccepted) {
             m_referenceNode = m_candidateNode;
             result = WTFMove(provisionalResult);
index 8253b4b..e1b5655 100644 (file)
 
 namespace WebCore {
 
-void StringCallback::scheduleCallback(ScriptExecutionContext* context, const String& data)
+void StringCallback::scheduleCallback(ScriptExecutionContext& context, const String& data)
 {
     RefPtr<StringCallback> protectedThis(this);
-    context->postTask([protectedThis, data] (ScriptExecutionContext&) {
+    context.postTask([protectedThis, data] (ScriptExecutionContext&) {
         protectedThis->handleEvent(data);
     });
 }
index f3aaaa5..72771e1 100644 (file)
@@ -43,7 +43,7 @@ public:
     virtual bool handleEvent(const String& data) = 0;
 
     // Helper to post callback task.
-    void scheduleCallback(ScriptExecutionContext*, const String& data);
+    void scheduleCallback(ScriptExecutionContext&, const String& data);
 };
 
 } // namespace WebCore
index 3c82a76..3759a5b 100644 (file)
@@ -37,11 +37,11 @@ NodeIteratorBase::NodeIteratorBase(Node& rootNode, unsigned whatToShow, RefPtr<N
 {
 }
 
-short NodeIteratorBase::acceptNode(Node* node) const
+short NodeIteratorBase::acceptNode(Node& node) const
 {
     // The bit twiddling here is done to map DOM node types, which are given as integers from
     // 1 through 14, to whatToShow bit masks.
-    if (!(((1 << (node->nodeType() - 1)) & m_whatToShow)))
+    if (!(((1 << (node.nodeType() - 1)) & m_whatToShow)))
         return NodeFilter::FILTER_SKIP;
     if (!m_filter)
         return NodeFilter::FILTER_ACCEPT;
index c93af86..cf13149 100644 (file)
@@ -41,7 +41,7 @@ public:
 
 protected:
     NodeIteratorBase(Node&, unsigned whatToShow, RefPtr<NodeFilter>&&);
-    short acceptNode(Node*) const;
+    short acceptNode(Node&) const;
 
 private:
     Ref<Node> m_root;
index 79e7b16..8927114 100644 (file)
@@ -55,7 +55,7 @@ Node* TreeWalker::parentNode()
         node = node->parentNode();
         if (!node)
             return nullptr;
-        short acceptNodeResult = acceptNode(node.get());
+        short acceptNodeResult = acceptNode(*node);
         if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
             return setCurrent(node.releaseNonNull());
     }
@@ -65,7 +65,7 @@ Node* TreeWalker::parentNode()
 Node* TreeWalker::firstChild()
 {
     for (RefPtr<Node> node = m_current->firstChild(); node; ) {
-        short acceptNodeResult = acceptNode(node.get());
+        short acceptNodeResult = acceptNode(*node);
         switch (acceptNodeResult) {
             case NodeFilter::FILTER_ACCEPT:
                 m_current = node.releaseNonNull();
@@ -96,7 +96,7 @@ Node* TreeWalker::firstChild()
 Node* TreeWalker::lastChild()
 {
     for (RefPtr<Node> node = m_current->lastChild(); node; ) {
-        short acceptNodeResult = acceptNode(node.get());
+        short acceptNodeResult = acceptNode(*node);
         switch (acceptNodeResult) {
             case NodeFilter::FILTER_ACCEPT:
                 m_current = node.releaseNonNull();
@@ -133,7 +133,7 @@ template<TreeWalker::SiblingTraversalType type> Node* TreeWalker::traverseSiblin
     auto isNext = type == SiblingTraversalType::Next;
     while (true) {
         for (RefPtr<Node> sibling = isNext ? node->nextSibling() : node->previousSibling(); sibling; ) {
-            short acceptNodeResult = acceptNode(sibling.get());
+            short acceptNodeResult = acceptNode(*sibling);
             if (acceptNodeResult == NodeFilter::FILTER_ACCEPT) {
                 m_current = sibling.releaseNonNull();
                 return m_current.ptr();
@@ -146,7 +146,7 @@ template<TreeWalker::SiblingTraversalType type> Node* TreeWalker::traverseSiblin
         node = node->parentNode();
         if (!node || node == &root())
             return nullptr;
-        short acceptNodeResult = acceptNode(node.get());
+        short acceptNodeResult = acceptNode(*node);
         if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
             return nullptr;
     }
@@ -168,12 +168,12 @@ Node* TreeWalker::previousNode()
     while (node != &root()) {
         while (Node* previousSibling = node->previousSibling()) {
             node = previousSibling;
-            short acceptNodeResult = acceptNode(node.get());
+            short acceptNodeResult = acceptNode(*node);
             if (acceptNodeResult == NodeFilter::FILTER_REJECT)
                 continue;
             while (Node* lastChild = node->lastChild()) {
                 node = lastChild;
-                acceptNodeResult = acceptNode(node.get());
+                acceptNodeResult = acceptNode(*node);
                 if (acceptNodeResult == NodeFilter::FILTER_REJECT)
                     break;
             }
@@ -188,7 +188,7 @@ Node* TreeWalker::previousNode()
         if (!parent)
             return nullptr;
         node = parent;
-        short acceptNodeResult = acceptNode(node.get());
+        short acceptNodeResult = acceptNode(*node);
         if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
             return setCurrent(node.releaseNonNull());
     }
@@ -201,7 +201,7 @@ Node* TreeWalker::nextNode()
 Children:
     while (Node* firstChild = node->firstChild()) {
         node = firstChild;
-        short acceptNodeResult = acceptNode(node.get());
+        short acceptNodeResult = acceptNode(*node);
         if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
             return setCurrent(node.releaseNonNull());
         if (acceptNodeResult == NodeFilter::FILTER_REJECT)
@@ -209,7 +209,7 @@ Children:
     }
     while (Node* nextSibling = NodeTraversal::nextSkippingChildren(*node, &root())) {
         node = nextSibling;
-        short acceptNodeResult = acceptNode(node.get());
+        short acceptNodeResult = acceptNode(*node);
         if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
             return setCurrent(node.releaseNonNull());
         if (acceptNodeResult == NodeFilter::FILTER_SKIP)
index 5090186..aa18653 100644 (file)
@@ -55,11 +55,11 @@ using ExecuteSQLCallback = Inspector::DatabaseBackendDispatcherHandler::ExecuteS
 
 namespace {
 
-void reportTransactionFailed(ExecuteSQLCallback& requestCallback, SQLError* error)
+void reportTransactionFailed(ExecuteSQLCallback& requestCallback, SQLError& error)
 {
     auto errorObject = Inspector::Protocol::Database::Error::create()
-        .setMessage(error->message())
-        .setCode(error->code())
+        .setMessage(error.message())
+        .setCode(error.code())
         .release();
     requestCallback.sendSuccess(nullptr, nullptr, WTFMove(errorObject));
 }
@@ -75,9 +75,9 @@ private:
     StatementCallback(Ref<ExecuteSQLCallback>&& requestCallback)
         : m_requestCallback(WTFMove(requestCallback)) { }
 
-    bool handleEvent(SQLTransaction*, SQLResultSet* resultSet) final
+    bool handleEvent(SQLTransaction&, SQLResultSet& resultSet) final
     {
-        auto& rowList = resultSet->rows();
+        auto& rowList = resultSet.rows();
 
         auto columnNames = Inspector::Protocol::Array<String>::create();
         for (auto& column : rowList.columnNames())
@@ -110,7 +110,7 @@ private:
     StatementErrorCallback(Ref<ExecuteSQLCallback>&& requestCallback)
         : m_requestCallback(WTFMove(requestCallback)) { }
 
-    bool handleEvent(SQLTransaction*, SQLError* error) final
+    bool handleEvent(SQLTransaction&, SQLError& error) final
     {
         reportTransactionFailed(m_requestCallback.copyRef(), error);
         return true;
@@ -131,14 +131,14 @@ private:
         : m_sqlStatement(sqlStatement)
         , m_requestCallback(WTFMove(requestCallback)) { }
 
-    bool handleEvent(SQLTransaction* transaction) final
+    bool handleEvent(SQLTransaction& transaction) final
     {
         if (!m_requestCallback->isActive())
             return true;
 
         Ref<SQLStatementCallback> callback(StatementCallback::create(m_requestCallback.copyRef()));
         Ref<SQLStatementErrorCallback> errorCallback(StatementErrorCallback::create(m_requestCallback.copyRef()));
-        transaction->executeSql(m_sqlStatement, { }, WTFMove(callback), WTFMove(errorCallback));
+        transaction.executeSql(m_sqlStatement, { }, WTFMove(callback), WTFMove(errorCallback));
         return true;
     }
 
@@ -157,7 +157,7 @@ private:
     TransactionErrorCallback(Ref<ExecuteSQLCallback>&& requestCallback)
         : m_requestCallback(WTFMove(requestCallback)) { }
 
-    bool handleEvent(SQLError* error) final
+    bool handleEvent(SQLError& error) final
     {
         reportTransactionFailed(m_requestCallback.get(), error);
         return true;
index 17f9d16..e6e96f2 100644 (file)
@@ -38,7 +38,7 @@ class IntersectionObserverEntry;
 class IntersectionObserverCallback : public RefCounted<IntersectionObserverCallback> {
 public:
     virtual ~IntersectionObserverCallback() { }
-    virtual bool handleEvent(Vector<RefPtr<IntersectionObserverEntry>>, IntersectionObserver*) = 0;
+    virtual bool handleEvent(const Vector<RefPtr<IntersectionObserverEntry>>&, IntersectionObserver&) = 0;
 };
 
 } // namespace WebCore
index 8d4bfa9..b2cce72 100644 (file)
@@ -99,7 +99,7 @@ void PerformanceObserver::deliver()
 
     Vector<RefPtr<PerformanceEntry>> entries = WTFMove(m_entriesToDeliver);
     auto list = PerformanceObserverEntryList::create(WTFMove(entries));
-    m_callback->handleEvent(list.ptr(), this);
+    m_callback->handleEvent(list, *this);
 }
 
 } // namespace WebCore
index 9135c39..1b3a396 100644 (file)
@@ -37,7 +37,7 @@ class PerformanceObserverEntryList;
 class PerformanceObserverCallback : public RefCounted<PerformanceObserverCallback> {
 public:
     virtual ~PerformanceObserverCallback() { }
-    virtual bool handleEvent(PerformanceObserverEntryList*, PerformanceObserver*) = 0;
+    virtual bool handleEvent(PerformanceObserverEntryList&, PerformanceObserver&) = 0;
 };
 
 } // namespace WebCore
index a731960..341740d 100644 (file)
@@ -1,3 +1,14 @@
+2017-05-18  Sam Weinig  <sam@webkit.org>
+
+        [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.
+
+        * DOM/DOM.mm:
+        (-[DOMNodeFilter acceptNode:]):
+        Update to pass Node by reference.
+
 2017-05-19  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         [JSC][DFG][DOMJIT] Extend CheckDOM to CheckSubClass
index fffa261..33dbe7f 100644 (file)
@@ -27,6 +27,7 @@
 
 #import "DOM.h"
 
+#import "ExceptionHandlers.h"
 #import "DOMElementInternal.h"
 #import "DOMHTMLCanvasElement.h"
 #import "DOMHTMLTableCellElementInternal.h"
@@ -858,7 +859,9 @@ WebCore::NodeFilter* core(DOMNodeFilter *wrapper)
 
 - (short)acceptNode:(DOMNode *)node
 {
-    return core(self)->acceptNode(core(node));
+    if (!node)
+        raiseTypeErrorException();
+    return core(self)->acceptNode(*core(node));
 }
 
 @end