diff options
author | Arno Rehn <a.rehn@menlosystems.com> | 2019-01-15 18:07:18 +0100 |
---|---|---|
committer | Milian Wolff <milian.wolff@kdab.com> | 2019-03-29 21:06:14 +0000 |
commit | d91fd4fc4e57a22e1d268e4602017f629cfccf46 (patch) | |
tree | 9a50d8d1fc4320008a62e5d6cc4b81ee18eeabf5 /src/webchannel/qmetaobjectpublisher_p.h | |
parent | 984c4e6b4dd05561bb39f6daf305e520dfa9f0e6 (diff) | |
download | qtwebchannel-d91fd4fc4e57a22e1d268e4602017f629cfccf46.tar.gz |
Implement actual overload resolution
This implements host-side overload resolution. If a client invokes a method
by its name instead of its id, the overload resolution tries to find the best
match for the given arguments.
The JavaScript client implementation now defaults to invocation-by-name, except
when a method is invoked by its full signature. In that case, the invocation
is still performed by method id.
Change-Id: I09f12bdbfee2e84ff66a1454608468113f96e3ed
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
Diffstat (limited to 'src/webchannel/qmetaobjectpublisher_p.h')
-rw-r--r-- | src/webchannel/qmetaobjectpublisher_p.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/webchannel/qmetaobjectpublisher_p.h b/src/webchannel/qmetaobjectpublisher_p.h index 23a9b96..6030de2 100644 --- a/src/webchannel/qmetaobjectpublisher_p.h +++ b/src/webchannel/qmetaobjectpublisher_p.h @@ -148,6 +148,14 @@ public: void sendPendingPropertyUpdates(); /** + * Invoke the @p method on @p object with the arguments @p args. + * + * The return value of the method invocation is then serialized and a response message + * is returned. + */ + QVariant invokeMethod(QObject *const object, const QMetaMethod &method, const QJsonArray &args); + + /** * Invoke the method of index @p methodIndex on @p object with the arguments @p args. * * The return value of the method invocation is then serialized and a response message @@ -156,6 +164,16 @@ public: QVariant invokeMethod(QObject *const object, const int methodIndex, const QJsonArray &args); /** + * Invoke the method of name @p methodName on @p object with the arguments @p args. + * + * This method performs overload resolution on @p methodName. + * + * The return value of the method invocation is then serialized and a response message + * is returned. + */ + QVariant invokeMethod(QObject *const object, const QByteArray &methodName, const QJsonArray &args); + + /** * Set the value of property @p propertyIndex on @p object to @p value. */ void setProperty(QObject *object, const int propertyIndex, const QJsonValue &value); @@ -177,6 +195,26 @@ public: QVariant toVariant(const QJsonValue &value, int targetType) const; /** + * Assigns a score for the conversion from @p value to @p targetType. + * + * Scores can be compared to find the best match. The lower the score, the + * more preferable is the conversion. + * + * @sa invokeMethod, methodOverloadBadness + */ + int conversionScore(const QJsonValue &value, int targetType) const; + + /** + * Scores @p method against @p args. + * + * Scores can be compared to find the best match from a set of overloads. + * The lower the score, the more preferable is the method. + * + * @sa invokeMethod, conversionScore + */ + int methodOverloadBadness(const QMetaMethod &method, const QJsonArray &args) const; + + /** * Remove wrapped objects which last transport relation is with the passed transport object. */ void transportRemoved(QWebChannelAbstractTransport *transport); |