From patchwork Fri Aug 27 02:38:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13523 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 2DC54C3241 for ; Fri, 27 Aug 2021 02:38:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B92BD6894A; Fri, 27 Aug 2021 04:38:50 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ljlryFUz"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9518B68932 for ; Fri, 27 Aug 2021 04:38:46 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 34E4FBB0 for ; Fri, 27 Aug 2021 04:38:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1630031926; bh=X2IyT8bRk8g/GguloMinx4pjAVyKjtFSpK3MPSOqeI8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ljlryFUzhXHfR+cWUbphYYnUFjiS4rye4brVxXiWE0KBysnjLd7ftkbU/IImBNpvF TMdjRFF3CB3hjN3qFKblgPtkFI8miRAmeaTDQq605w0RCbbzZNpoqjq7E5QleUg1dD j29vpppPlFIJxs4Sdwac8N8pB0xyjj0tkCSrYWk4= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Aug 2021 05:38:25 +0300 Message-Id: <20210827023829.5871-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210827023829.5871-1-laurent.pinchart@ideasonboard.com> References: <20210827023829.5871-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 2/6] libcamera: base: bound_method: Remove BoundMethodMember specialization X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The BoundMethodMember specialization for the void return type is only needed to avoid accessing the ret_ member variable that is lacking from the corresponding BoundMethodPack specialization. By adding a BoundMethodPack::returnValue() function to read the member variable, we can remove the complete BoundMethodMember specialization. Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain --- include/libcamera/base/bound_method.h | 46 ++++++--------------------- 1 file changed, 10 insertions(+), 36 deletions(-) diff --git a/include/libcamera/base/bound_method.h b/include/libcamera/base/bound_method.h index 282f9b58ab60..9c212f1ecc3a 100644 --- a/include/libcamera/base/bound_method.h +++ b/include/libcamera/base/bound_method.h @@ -38,6 +38,11 @@ public: { } + R returnValue() + { + return ret_; + } + std::tuple...> args_; R ret_; }; @@ -51,6 +56,10 @@ public: { } + void returnValue() + { + } + std::tuple...> args_; }; @@ -160,7 +169,7 @@ public: auto pack = std::make_shared(args...); bool sync = BoundMethodBase::activatePack(pack, deleteMethod); - return sync ? pack->ret_ : R(); + return sync ? pack->returnValue() : R(); } R invoke(Args... args) override @@ -173,41 +182,6 @@ private: R (T::*func_)(Args...); }; -template -class BoundMethodMember : public BoundMethodArgs -{ -public: - using PackType = typename BoundMethodArgs::PackType; - - BoundMethodMember(T *obj, Object *object, void (T::*func)(Args...), - ConnectionType type = ConnectionTypeAuto) - : BoundMethodArgs(obj, object, type), func_(func) - { - } - - bool match(void (T::*func)(Args...)) const { return func == func_; } - - void activate(Args... args, bool deleteMethod = false) override - { - if (!this->object_) { - T *obj = static_cast(this->obj_); - return (obj->*func_)(args...); - } - - auto pack = std::make_shared(args...); - BoundMethodBase::activatePack(pack, deleteMethod); - } - - void invoke(Args... args) override - { - T *obj = static_cast(this->obj_); - return (obj->*func_)(args...); - } - -private: - void (T::*func_)(Args...); -}; - template class BoundMethodStatic : public BoundMethodArgs {