From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id uFznBmA7oGD75wAAgWs5BA (envelope-from ) for ; Sat, 15 May 2021 23:21:36 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id +EcRAmA7oGBrDQAA1q6Kng (envelope-from ) for ; Sat, 15 May 2021 21:21:36 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 8C0352D13A for ; Sat, 15 May 2021 23:21:35 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 7B2C929051; Sat, 15 May 2021 17:21:17 -0400 (EDT) Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) by mail.notmuchmail.org (Postfix) with ESMTPS id AB76227E2C for ; Sat, 15 May 2021 17:21:12 -0400 (EDT) Received: by mail-ot1-x32e.google.com with SMTP id t4-20020a05683014c4b02902ed26dd7a60so2350450otq.7 for ; Sat, 15 May 2021 14:21:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mtxXUhD68eASkyf0IqCqBkxabgKVn30kwSlwPFIudA4=; b=ga4x51urjKzHnlj7JjDWnM/W+S36gQnXWMshLfVIQSQXaoi75UuFBrGxf5LvxlKsJR yvlu0YwLXip+/kh1lnrs4mKRmbPKxv1xjQM8mQAwBEX+7llbHKGXwWpG7c4QrDvFjv0z 4s6jNiAm4RlfWVTO69LZDexq/g1aEmsx05JuLSzKWTPRK464wbRn3UgKNInwTpkuouTF 5TmNEYz5HqPxc5tjycqba7PfI9GomCA6auQ3ZsMRGuTLGVXBRbwx5iiWimv09T5kUhA6 rCdPnVIOEMvCZwnlX35qVuVXbK05ECd9htES7s62JeZs086f13hEs7SD+H7j+MovEnEd wbfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mtxXUhD68eASkyf0IqCqBkxabgKVn30kwSlwPFIudA4=; b=aWIrZbpHKUVifpJdF4iYeERAp5TgdYRc8HYwZOvXLpqltHj2GZ5Fvf2ENDhqIFmNfQ qAXdacTs9Pl1urJ0INHGG3HLhdvmJrdad1srpPUTPvhBdFzqaYjUs+wMv7zBwsUVnZga KbI6qVfr44+9BJWRJGZcKNtEH02oYRk2BWbeoCFw1Jz8u8svmyI6eLtcKQMxNL4z0MV5 ESiXEC14eqsOWc8kTUs0AAg8arGHR6kdv+uklRYEQp3OuWHyzi5ESLk2nJOand4rYULk iqws0IfhBSyaVEh6HbXZRA64Nzk8peIUpD1XXclncmY3KYm9LoP4/OFBMHmG4PH4fA6j sP/g== X-Gm-Message-State: AOAM531Exj8eWs69VQylJL2OB//FBGagz2+/tJWIOgm0jpt/bA6+hQzK CbUPtX+b0zAS61HparYClxulOtXqiGwxKw== X-Google-Smtp-Source: ABdhPJzJS9gC7ohsEGh/U/RjCPYAa5lFebgemANHKZsQl3BZ9qHVuC/X8haHj+SteCAirYIDUm92eQ== X-Received: by 2002:a9d:2ac8:: with SMTP id e66mr1919970otb.360.1621113666453; Sat, 15 May 2021 14:21:06 -0700 (PDT) Received: from localhost (fixed-187-189-165-231.totalplay.net. [187.189.165.231]) by smtp.gmail.com with ESMTPSA id x3sm2164698otj.8.2021.05.15.14.21.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 May 2021 14:21:06 -0700 (PDT) From: Felipe Contreras To: notmuch@notmuchmail.org Subject: [PATCH v3 1/7] ruby: simplify data get helper Date: Sat, 15 May 2021 16:20:57 -0500 Message-Id: <20210515212103.1001295-2-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210515212103.1001295-1-felipe.contreras@gmail.com> References: <20210515212103.1001295-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Message-ID-Hash: TQBC25H2YGEPDUIYOWSTCVB5T5N4OLKH X-Message-ID-Hash: TQBC25H2YGEPDUIYOWSTCVB5T5N4OLKH X-MailFrom: felipe.contreras@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Ali Polatel , Austin Clements , Tomi Ollila , Ludovic LANGE , Daniel Kahn Gillmor X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1621113695; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=N63f0oFglN6dQFD1C/jNzZS6gmMqPZOl/EGIMxI4QBg=; b=Fqx63J25gYLQappOVDbTmgloNQBMqIMZ3qcV0E0A3KN0Bc35AMmp8hBmVHpSszCRr+7nsO TrF+q0jml225x6KwlL7mohee6aDBqU5L+PLZTDC0Ebg6i1/n4UsOty6/CFg77t+igYLYio 8owGFtcdaYAeTAvtBMKHuLuwUlfGVGTWpz+Kb5zQ+Jt8/QoWdFq4xbRP2djFYLrYSW/nYz +QiZGii8TOseupWBEEZHpK3gS9evxoBovUtLs4w45QYHrYHVMyPb6uAEsgJ3vQt3Yzvf51 ymRwBCtLi15NAUXiXcc3LROSU7a0jqPrAswx43F+qd6WlvmFB9Ou7TN65zj9/Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1621113695; a=rsa-sha256; cv=none; b=cEP5JdOBNPHZUzfXuZzEUBoY7p148JJah5vZtQCKdWWvhgzHRL0+GxLBqFI4upZL0bsMqG HyE3zrYxmfE9GafD0M39tSzEnmQh1CkbC5nn79NSsXDfwRPWSf17g7+Gtc9T6zq+UPlqkD hWbii1fke4O8PmwBWPdV+TYhyAQ8I0sLp9CMdOg8v8treV6xBMTdRs9jVW+9iN6Tjs8JdR Xq3NWEioEgwbD6ClqEnviNdcNLzG2hC9EYwmeNK30Dn0kyi67miBhDN5c8+StxkPpqduWF m0A/Ws4KVBB4xypJYysIsBIBfRrZfFVFbRGnhk3m81RfZDCd9WsvLpQs0827vQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20161025 header.b=ga4x51ur; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -0.94 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20161025 header.b=ga4x51ur; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 8C0352D13A X-Spam-Score: -0.94 X-Migadu-Scanner: scn0.migadu.com X-TUID: Ik+JqJQhnPXg Data_Get_Struct is nothing but a macro that calls rb_data_object_get with a cast (unnecessary in C). #define Data_Get_Struct(obj, type, sval) \ ((sval) = RBIMPL_CAST((type*)rb_data_object_get(obj))) We can use rb_data_object_get directly, and this way we don't need to pass the type, which is unnecessary information. Signed-off-by: Felipe Contreras --- bindings/ruby/defs.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h index 46e2caf8..8fb47b4c 100644 --- a/bindings/ruby/defs.h +++ b/bindings/ruby/defs.h @@ -55,39 +55,39 @@ extern ID ID_db_mode; # define RSTRING_PTR(v) (RSTRING((v))->ptr) #endif /* !defined (RSTRING_PTR) */ -#define Data_Get_Notmuch_Object(obj, type, message, ptr) \ +#define Data_Get_Notmuch_Object(obj, message, ptr) \ do { \ - Data_Get_Struct ((obj), type, (ptr)); \ + (ptr) = rb_data_object_get ((obj)); \ if (!(ptr)) \ rb_raise (rb_eRuntimeError, (message)); \ } while (0) #define Data_Get_Notmuch_Database(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), notmuch_database_t, "database closed", (ptr)) + Data_Get_Notmuch_Object ((obj), "database closed", (ptr)) #define Data_Get_Notmuch_Directory(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), notmuch_directory_t, "directory destroyed", (ptr)) + Data_Get_Notmuch_Object ((obj), "directory destroyed", (ptr)) #define Data_Get_Notmuch_FileNames(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), notmuch_filenames_t, "filenames destroyed", (ptr)) + Data_Get_Notmuch_Object ((obj), "filenames destroyed", (ptr)) #define Data_Get_Notmuch_Query(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), notmuch_query_t, "query destroyed", (ptr)) + Data_Get_Notmuch_Object ((obj), "query destroyed", (ptr)) #define Data_Get_Notmuch_Threads(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), notmuch_threads_t, "threads destroyed", (ptr)) + Data_Get_Notmuch_Object ((obj), "threads destroyed", (ptr)) #define Data_Get_Notmuch_Messages(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), notmuch_messages_t, "messages destroyed", (ptr)) + Data_Get_Notmuch_Object ((obj), "messages destroyed", (ptr)) #define Data_Get_Notmuch_Thread(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), notmuch_thread_t, "thread destroyed", (ptr)) + Data_Get_Notmuch_Object ((obj), "thread destroyed", (ptr)) #define Data_Get_Notmuch_Message(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), notmuch_message_t, "message destroyed", (ptr)) + Data_Get_Notmuch_Object ((obj), "message destroyed", (ptr)) #define Data_Get_Notmuch_Tags(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), notmuch_tags_t, "tags destroyed", (ptr)) + Data_Get_Notmuch_Object ((obj), "tags destroyed", (ptr)) /* status.c */ void -- 2.31.1