From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id EIhABGc7oGAT5AAAgWs5BA (envelope-from ) for ; Sat, 15 May 2021 23:21:43 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id wBd0O2Y7oGC4FQAAB5/wlQ (envelope-from ) for ; Sat, 15 May 2021 21:21:42 +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 98690B6FB for ; Sat, 15 May 2021 23:21:42 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id BD24F28CFE; Sat, 15 May 2021 17:21:22 -0400 (EDT) Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) by mail.notmuchmail.org (Postfix) with ESMTPS id EE17D27E2B for ; Sat, 15 May 2021 17:21:12 -0400 (EDT) Received: by mail-ot1-x32c.google.com with SMTP id t10-20020a05683022eab0290304ed8bc759so2326566otc.12 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=LTJyh5SmlSxNg0Xpg63Cv1mIU/l7fdL5L+1t/sQs8tE=; b=Xv3Bzfli+qqgUfkPYVtHZhEdgfFWW6VCCzJ5vUVUHpiC9/AZfYeAMXqNioPsBPnTn2 P/AE1sc9DjrwckWCXt3cTW4QYpGJSSTmjddizz+0Vwcq1HsAvYiEb67EiddjWWHbvAsq dc1tr+OaBDszUM4drupgoTesQiAFyrP3ehNRWSmCtnn6Zzwz505194vOuQGMYIJVrmx1 5e6BM3cAQl/DDgPDaeRKXGTn+6ROcnW7lXUtQjk67LIduQwsRqQyr0b0Jy/NQBEialu5 4l++QLh2vIkN44C5mOMJnayjcXk8BAiO2qA/B7fym0kT6/Mb6s5AtDkEmvz7zNHv+JpW ByHQ== 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=LTJyh5SmlSxNg0Xpg63Cv1mIU/l7fdL5L+1t/sQs8tE=; b=B8zCtMC6vCm8f6XFfJONal75zfOUYxNddL3nBrMjxIWtKO6GaqknYjEcVyyz9L5D7r IQpBC/HmqpWbcXUbd89gSmXMpskenrwVqOdnUwNxZIrohGyn/QEGdsKYr7ROhuAGylfV n54WyegCVM/NugTOnLMhXxVkcSgl9fR529C2ftYzl20dzHGAhI5jrcjuGmJgKRusS9WZ ANIRF4JTVENiRCE63KYbniv7+IEgKS/uME6+i0DodtpLOvwsWD9Lo191XcJwicm8amXB A8eAGrTA/dKigEsRZjsKi5edXHd/MFFd8z3/wut3RTwID6iuskrVveDm2YRYsxx3Ufib BA5g== X-Gm-Message-State: AOAM532+ga9dz2YAJNiIC3WbldzirVBvKS5kQ8RvuV8IXl1HZHr/KpKe J7B+fBHnZNJ/rEJgCcZsk7a9EEtWVz22nA== X-Google-Smtp-Source: ABdhPJwM4y7QoDF71yFkiJZ0JZhXXws/6m7jePIb08CdgzfM2CAI9Xza2wnTCy2GnoPVXH0d2pCgqA== X-Received: by 2002:a05:6830:1bd4:: with SMTP id v20mr46340793ota.101.1621113671392; Sat, 15 May 2021 14:21:11 -0700 (PDT) Received: from localhost (fixed-187-189-165-231.totalplay.net. [187.189.165.231]) by smtp.gmail.com with ESMTPSA id 186sm2107916oof.14.2021.05.15.14.21.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 May 2021 14:21:11 -0700 (PDT) From: Felipe Contreras To: notmuch@notmuchmail.org Subject: [PATCH v3 4/7] ruby: create Data_Wrap_Notmuch_Object helper Date: Sat, 15 May 2021 16:21:00 -0500 Message-Id: <20210515212103.1001295-5-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: EX2HWJVS47TD6QEEL5JE2NLJAV3TVYY4 X-Message-ID-Hash: EX2HWJVS47TD6QEEL5JE2NLJAV3TVYY4 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=1621113702; 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=S42XS7/QfHognT4e+m7JHNSbsKGLJXHoNEhGD85C62c=; b=sFX4nKgoVnnQjSCaP7Zk9PAAj2I35WedcvZoH03fKzPYPQKZOLaDfo1ceoyc/Ku/5fu0Hz +kuAYe1yzuENi4tjNbEJ6/fiyJtNWb5qfXDYwChJHvnHzjjxO2bL6biRMPDangayfRU9u8 5DXAx8Y/BeWP9wOrIyGwR7gAhAr0on0HLlyxTw2tRRYw2uo9KXXXZ6Jt1fvvEE7LuPLwz2 6i+BPHW1V73kuMfx9p/sMCZckzDeyvacXoBtVb7Zb0aukMQwiQ48SSrjf/8ANs9HHN0Bz/ z2wmbOIIR6zpslsS2r8ZBQfJ6HmCeFq2BjYiPUre8uk+QjgrpIaNaql1ZWg1BA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1621113702; a=rsa-sha256; cv=none; b=XPEqZtm+kGXi+vZu5XfGp8CHMt1wU0lB0aqvyQTTyudbJX3FSOJP7GUkoMcCDV9qeRPqLz jYhXgjY1akvdSs2sVG3L5Pbt0mA9HR6i51n43IXnltbLztX0RiraCOjkmhbddeng/8ZzhO dQ9HvSPasAdjMNsyWwHcpWGTGv0WH8uUeR61o+wLQZJ/2ARpX8P2IcQVk2tp8W3LgMc2kj 4x7JYrtwGgIGek7zQg+MHmbGHjEv/xxVAiSU+zKX3oF3R0FxU+5EAPmkXsFLPD/l5kcS14 Mxo0UPAWElj3dfgEPor+HakqdVf0tOj/7YPo2p8SHuXSf8e/pkuzJICisObtMg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20161025 header.b=Xv3Bzfli; 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=Xv3Bzfli; 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: 98690B6FB X-Spam-Score: -0.94 X-Migadu-Scanner: scn0.migadu.com X-TUID: FxQl0SRGULKh This makes the code more maintainable and will help in further patches. No functional changes. Signed-off-by: Felipe Contreras --- bindings/ruby/database.c | 14 +++++++------- bindings/ruby/defs.h | 3 +++ bindings/ruby/directory.c | 4 ++-- bindings/ruby/message.c | 6 +++--- bindings/ruby/messages.c | 4 ++-- bindings/ruby/query.c | 4 ++-- bindings/ruby/thread.c | 6 +++--- bindings/ruby/threads.c | 2 +- 8 files changed, 23 insertions(+), 20 deletions(-) diff --git a/bindings/ruby/database.c b/bindings/ruby/database.c index 416eb709..b9ad3373 100644 --- a/bindings/ruby/database.c +++ b/bindings/ruby/database.c @@ -23,7 +23,7 @@ VALUE notmuch_rb_database_alloc (VALUE klass) { - return Data_Wrap_Struct (klass, NULL, NULL, NULL); + return Data_Wrap_Notmuch_Object (klass, NULL); } /* @@ -266,7 +266,7 @@ notmuch_rb_database_get_directory (VALUE self, VALUE pathv) ret = notmuch_database_get_directory (db, path, &dir); notmuch_rb_status_raise (ret); if (dir) - return Data_Wrap_Struct (notmuch_rb_cDirectory, NULL, NULL, dir); + return Data_Wrap_Notmuch_Object (notmuch_rb_cDirectory, dir); return Qnil; } @@ -293,7 +293,7 @@ notmuch_rb_database_add_message (VALUE self, VALUE pathv) ret = notmuch_database_index_file (db, path, NULL, &message); notmuch_rb_status_raise (ret); - return rb_assoc_new (Data_Wrap_Struct (notmuch_rb_cMessage, NULL, NULL, message), + return rb_assoc_new (Data_Wrap_Notmuch_Object (notmuch_rb_cMessage, message), (ret == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) ? Qtrue : Qfalse); } @@ -344,7 +344,7 @@ notmuch_rb_database_find_message (VALUE self, VALUE idv) notmuch_rb_status_raise (ret); if (message) - return Data_Wrap_Struct (notmuch_rb_cMessage, NULL, NULL, message); + return Data_Wrap_Notmuch_Object (notmuch_rb_cMessage, message); return Qnil; } @@ -370,7 +370,7 @@ notmuch_rb_database_find_message_by_filename (VALUE self, VALUE pathv) notmuch_rb_status_raise (ret); if (message) - return Data_Wrap_Struct (notmuch_rb_cMessage, NULL, NULL, message); + return Data_Wrap_Notmuch_Object (notmuch_rb_cMessage, message); return Qnil; } @@ -395,7 +395,7 @@ notmuch_rb_database_get_all_tags (VALUE self) rb_raise (notmuch_rb_eBaseError, "%s", msg); } - return Data_Wrap_Struct (notmuch_rb_cTags, NULL, NULL, tags); + return Data_Wrap_Notmuch_Object (notmuch_rb_cTags, tags); } /* @@ -419,5 +419,5 @@ notmuch_rb_database_query_create (VALUE self, VALUE qstrv) if (!query) rb_raise (notmuch_rb_eMemoryError, "Out of memory"); - return Data_Wrap_Struct (notmuch_rb_cQuery, NULL, NULL, query); + return Data_Wrap_Notmuch_Object (notmuch_rb_cQuery, query); } diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h index 12538a3a..fcf1ea39 100644 --- a/bindings/ruby/defs.h +++ b/bindings/ruby/defs.h @@ -64,6 +64,9 @@ extern ID ID_db_mode; } \ } while (0) +#define Data_Wrap_Notmuch_Object(klass, ptr) \ + Data_Wrap_Struct ((klass), NULL, NULL, (ptr)) + #define Data_Get_Notmuch_Database(obj, ptr) \ Data_Get_Notmuch_Object ((obj), (ptr)) diff --git a/bindings/ruby/directory.c b/bindings/ruby/directory.c index fe5fc46d..36ef3984 100644 --- a/bindings/ruby/directory.c +++ b/bindings/ruby/directory.c @@ -92,7 +92,7 @@ notmuch_rb_directory_get_child_files (VALUE self) fnames = notmuch_directory_get_child_files (dir); - return Data_Wrap_Struct (notmuch_rb_cFileNames, NULL, NULL, fnames); + return Data_Wrap_Notmuch_Object (notmuch_rb_cFileNames, fnames); } /* @@ -111,5 +111,5 @@ notmuch_rb_directory_get_child_directories (VALUE self) fnames = notmuch_directory_get_child_directories (dir); - return Data_Wrap_Struct (notmuch_rb_cFileNames, NULL, NULL, fnames); + return Data_Wrap_Notmuch_Object (notmuch_rb_cFileNames, fnames); } diff --git a/bindings/ruby/message.c b/bindings/ruby/message.c index 6ea82afa..1990bb97 100644 --- a/bindings/ruby/message.c +++ b/bindings/ruby/message.c @@ -89,7 +89,7 @@ notmuch_rb_message_get_replies (VALUE self) messages = notmuch_message_get_replies (message); - return Data_Wrap_Struct (notmuch_rb_cMessages, NULL, NULL, messages); + return Data_Wrap_Notmuch_Object (notmuch_rb_cMessages, messages); } /* @@ -125,7 +125,7 @@ notmuch_rb_message_get_filenames (VALUE self) fnames = notmuch_message_get_filenames (message); - return Data_Wrap_Struct (notmuch_rb_cFileNames, NULL, NULL, fnames); + return Data_Wrap_Notmuch_Object (notmuch_rb_cFileNames, fnames); } /* @@ -226,7 +226,7 @@ notmuch_rb_message_get_tags (VALUE self) if (!tags) rb_raise (notmuch_rb_eMemoryError, "Out of memory"); - return Data_Wrap_Struct (notmuch_rb_cTags, NULL, NULL, tags); + return Data_Wrap_Notmuch_Object (notmuch_rb_cTags, tags); } /* diff --git a/bindings/ruby/messages.c b/bindings/ruby/messages.c index a337feeb..3d1669ee 100644 --- a/bindings/ruby/messages.c +++ b/bindings/ruby/messages.c @@ -53,7 +53,7 @@ notmuch_rb_messages_each (VALUE self) for (; notmuch_messages_valid (messages); notmuch_messages_move_to_next (messages)) { message = notmuch_messages_get (messages); - rb_yield (Data_Wrap_Struct (notmuch_rb_cMessage, NULL, NULL, message)); + rb_yield (Data_Wrap_Notmuch_Object (notmuch_rb_cMessage, message)); } return self; @@ -76,5 +76,5 @@ notmuch_rb_messages_collect_tags (VALUE self) if (!tags) rb_raise (notmuch_rb_eMemoryError, "Out of memory"); - return Data_Wrap_Struct (notmuch_rb_cTags, NULL, NULL, tags); + return Data_Wrap_Notmuch_Object (notmuch_rb_cTags, tags); } diff --git a/bindings/ruby/query.c b/bindings/ruby/query.c index 8b46d700..b0fb4ea7 100644 --- a/bindings/ruby/query.c +++ b/bindings/ruby/query.c @@ -142,7 +142,7 @@ notmuch_rb_query_search_threads (VALUE self) if (status) notmuch_rb_status_raise (status); - return Data_Wrap_Struct (notmuch_rb_cThreads, NULL, NULL, threads); + return Data_Wrap_Notmuch_Object (notmuch_rb_cThreads, threads); } /* @@ -163,7 +163,7 @@ notmuch_rb_query_search_messages (VALUE self) if (status) notmuch_rb_status_raise (status); - return Data_Wrap_Struct (notmuch_rb_cMessages, NULL, NULL, messages); + return Data_Wrap_Notmuch_Object (notmuch_rb_cMessages, messages); } /* diff --git a/bindings/ruby/thread.c b/bindings/ruby/thread.c index 9b295981..e09be147 100644 --- a/bindings/ruby/thread.c +++ b/bindings/ruby/thread.c @@ -88,7 +88,7 @@ notmuch_rb_thread_get_toplevel_messages (VALUE self) if (!messages) rb_raise (notmuch_rb_eMemoryError, "Out of memory"); - return Data_Wrap_Struct (notmuch_rb_cMessages, NULL, NULL, messages); + return Data_Wrap_Notmuch_Object (notmuch_rb_cMessages, messages); } /* @@ -108,7 +108,7 @@ notmuch_rb_thread_get_messages (VALUE self) if (!messages) rb_raise (notmuch_rb_eMemoryError, "Out of memory"); - return Data_Wrap_Struct (notmuch_rb_cMessages, NULL, NULL, messages); + return Data_Wrap_Notmuch_Object (notmuch_rb_cMessages, messages); } /* @@ -209,5 +209,5 @@ notmuch_rb_thread_get_tags (VALUE self) if (!tags) rb_raise (notmuch_rb_eMemoryError, "Out of memory"); - return Data_Wrap_Struct (notmuch_rb_cTags, NULL, NULL, tags); + return Data_Wrap_Notmuch_Object (notmuch_rb_cTags, tags); } diff --git a/bindings/ruby/threads.c b/bindings/ruby/threads.c index 5885f565..19e09a7e 100644 --- a/bindings/ruby/threads.c +++ b/bindings/ruby/threads.c @@ -53,7 +53,7 @@ notmuch_rb_threads_each (VALUE self) for (; notmuch_threads_valid (threads); notmuch_threads_move_to_next (threads)) { thread = notmuch_threads_get (threads); - rb_yield (Data_Wrap_Struct (notmuch_rb_cThread, NULL, NULL, thread)); + rb_yield (Data_Wrap_Notmuch_Object (notmuch_rb_cThread, thread)); } return self; -- 2.31.1