aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorArno Rehn <a.rehn@menlosystems.com>2019-01-15 18:07:18 +0100
committerMilian Wolff <milian.wolff@kdab.com>2019-03-29 21:06:14 +0000
commitd91fd4fc4e57a22e1d268e4602017f629cfccf46 (patch)
tree9a50d8d1fc4320008a62e5d6cc4b81ee18eeabf5 /examples
parent984c4e6b4dd05561bb39f6daf305e520dfa9f0e6 (diff)
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 'examples')
-rw-r--r--examples/webchannel/shared/qwebchannel.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/examples/webchannel/shared/qwebchannel.js b/examples/webchannel/shared/qwebchannel.js
index 800a66e..9108a61 100644
--- a/examples/webchannel/shared/qwebchannel.js
+++ b/examples/webchannel/shared/qwebchannel.js
@@ -339,6 +339,10 @@ function QObject(name, data, webChannel)
{
var methodName = methodData[0];
var methodIdx = methodData[1];
+
+ // Fully specified methods are invoked by id, others by name for host-side overload resolution
+ var invokedMethod = methodName[methodName.length - 1] === ')' ? methodIdx : methodName
+
object[methodName] = function() {
var args = [];
var callback;
@@ -357,7 +361,7 @@ function QObject(name, data, webChannel)
webChannel.exec({
"type": QWebChannelMessageTypes.invokeMethod,
"object": object.__id__,
- "method": methodIdx,
+ "method": invokedMethod,
"args": args
}, function(response) {
if (response !== undefined) {