Patch Detail
Show a patch.
GET /api/patches/2484/?format=api
{ "id": 2484, "url": "https://patchwork.libcamera.org/api/patches/2484/?format=api", "web_url": "https://patchwork.libcamera.org/patch/2484/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20200102235311.12009-2-laurent.pinchart@ideasonboard.com>", "date": "2020-01-02T23:53:11", "name": "[libcamera-devel,2/2] libcamera: object: Support reference arguments in invokeMethod()", "commit_ref": "1acad98f7d162ee4e9d5f869489b0c3b17ad80aa", "pull_url": null, "state": "accepted", "archived": false, "hash": "c0d29d9e0b596e722682a94208ba4524bdc98793", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/2484/mbox/", "series": [ { "id": 597, "url": "https://patchwork.libcamera.org/api/series/597/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=597", "date": "2020-01-02T23:53:10", "name": "[libcamera-devel,1/2] test: object-invoke: Test invocation of method taking a reference argument", "version": 1, "mbox": "https://patchwork.libcamera.org/series/597/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/2484/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/2484/checks/", "tags": {}, "headers": { "Return-Path": "<laurent.pinchart@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7EAB660469\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 3 Jan 2020 00:53:25 +0100 (CET)", "from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1AA7E9A5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 3 Jan 2020 00:53:25 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1578009205;\n\tbh=XvyIQc2YGGrvrBKw69hPk6jZi/Ge2LUwEmcv43pmvL4=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=pLrAluxUBFYmhAX6ELIpHnnPQmbZDTWyLtOC4+vfTcAlEgLri/m6WuQ8EyN0fTrdl\n\tWOrf9M6Pgb+5kYfeYGHTvOYFaj/RbfOTqwcwIQIzujtsCEDv8YW2fdwm33tIC8yl2B\n\tIPPintOO7B5gMX2+3xeMHKDbCO2bKsrwAudn7wzw=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 3 Jan 2020 01:53:11 +0200", "Message-Id": "<20200102235311.12009-2-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.24.1", "In-Reply-To": "<20200102235311.12009-1-laurent.pinchart@ideasonboard.com>", "References": "<20200102235311.12009-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 2/2] libcamera: object: Support reference\n\targuments in invokeMethod()", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "X-List-Received-Date": "Thu, 02 Jan 2020 23:53:25 -0000" }, "content": "Invoking a method that takes a reference argument with\nObject::invokeMethod() results in a compilation error:\n\n../test/object-invoke.cpp:131:11: error: no matching member function for call to 'invokeMethod'\n object_.invokeMethod(&InvokedObject::methodWithReference,\n ~~~~~~~~^~~~~~~~~~~~\n../include/libcamera/object.h:33:7: note: candidate template ignored: deduced conflicting types for parameter 'Args' (<const int &> vs. <int>)\n void invokeMethod(void (T::*func)(Args...), ConnectionType type, Args... args)\n\nThis is due to the fact that implicit type conversions (from value to\nreference in this case) takes place after template argument type\ndeduction, during overload resolution. A similar issue would occur if\nT::func took a long argument and invokeMethod() was called with an in\nargument.\n\nFix this by specifying to sets of argument types in the invokeMethod()\ntemplate, one for the arguments to the invoked method, and one for the\narguments to invokeMethod() itself. The compiler can then first perform\ntype deduction separately, and implicit conversion in a second step.\n\nReported-by: Paul Elder <paul.elder@ideasonboard.com>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/object.h | 10 ++++++----\n 1 file changed, 6 insertions(+), 4 deletions(-)", "diff": "diff --git a/include/libcamera/object.h b/include/libcamera/object.h\nindex 86e0f7265865..21b70460b516 100644\n--- a/include/libcamera/object.h\n+++ b/include/libcamera/object.h\n@@ -29,13 +29,15 @@ public:\n \n \tvoid postMessage(std::unique_ptr<Message> msg);\n \n-\ttemplate<typename T, typename... Args, typename std::enable_if<std::is_base_of<Object, T>::value>::type * = nullptr>\n-\tvoid invokeMethod(void (T::*func)(Args...), ConnectionType type, Args... args)\n+\ttemplate<typename T, typename... FuncArgs, typename... Args,\n+\t\t typename std::enable_if<std::is_base_of<Object, T>::value>::type * = nullptr>\n+\tvoid invokeMethod(void (T::*func)(FuncArgs...), ConnectionType type,\n+\t\t\t Args... args)\n \t{\n \t\tT *obj = static_cast<T *>(this);\n \t\tBoundMethodBase *method =\n-\t\t\tnew BoundMemberMethod<T, Args...>(obj, this, func, type);\n-\t\tvoid *pack = new typename BoundMemberMethod<T, Args...>::PackType{ args... };\n+\t\t\tnew BoundMemberMethod<T, FuncArgs...>(obj, this, func, type);\n+\t\tvoid *pack = new typename BoundMemberMethod<T, FuncArgs...>::PackType{ args... };\n \n \t\tmethod->activatePack(pack, true);\n \t}\n", "prefixes": [ "libcamera-devel", "2/2" ] }