(methodData)
| 326 | } |
| 327 | |
| 328 | function addMethod(methodData) |
| 329 | { |
| 330 | var methodName = methodData[0]; |
| 331 | var methodIdx = methodData[1]; |
| 332 | |
| 333 | // Fully specified methods are invoked by id, others by name for host-side overload resolution |
| 334 | var invokedMethod = methodName[methodName.length - 1] === ')' ? methodIdx : methodName |
| 335 | |
| 336 | object[methodName] = function() { |
| 337 | var args = []; |
| 338 | var callback; |
| 339 | var errCallback; |
| 340 | for (var i = 0; i < arguments.length; ++i) { |
| 341 | var argument = arguments[i]; |
| 342 | if (typeof argument === "function") |
| 343 | callback = argument; |
| 344 | else if (argument instanceof QObject && webChannel.objects[argument.__id__] !== undefined) |
| 345 | args.push({ |
| 346 | "id": argument.__id__ |
| 347 | }); |
| 348 | else |
| 349 | args.push(argument); |
| 350 | } |
| 351 | |
| 352 | var result; |
| 353 | // during test, webChannel.exec synchronously calls the callback |
| 354 | // therefore, the promise must be constucted before calling |
| 355 | // webChannel.exec to ensure the callback is set up |
| 356 | if (!callback && (typeof(Promise) === 'function')) { |
| 357 | result = new Promise(function(resolve, reject) { |
| 358 | callback = resolve; |
| 359 | errCallback = reject; |
| 360 | }); |
| 361 | } |
| 362 | |
| 363 | webChannel.exec({ |
| 364 | "type": QWebChannelMessageTypes.invokeMethod, |
| 365 | "object": object.__id__, |
| 366 | "method": invokedMethod, |
| 367 | "args": args |
| 368 | }, function(response) { |
| 369 | if (response !== undefined) { |
| 370 | var result = object.unwrapQObject(response); |
| 371 | if (callback) { |
| 372 | (callback)(result); |
| 373 | } |
| 374 | } else if (errCallback) { |
| 375 | (errCallback)(); |
| 376 | } |
| 377 | }); |
| 378 | |
| 379 | return result; |
| 380 | }; |
| 381 | } |
| 382 | |
| 383 | function bindGetterSetter(propertyInfo) |
| 384 | { |
nothing calls this directly
no outgoing calls
no test coverage detected