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 OGnqKG87oGDr5QAAgWs5BA (envelope-from ) for ; Sat, 15 May 2021 23:21:51 +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 6OCPJG87oGDcGQAAB5/wlQ (envelope-from ) for ; Sat, 15 May 2021 21:21:51 +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)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 386E0B704 for ; Sat, 15 May 2021 23:21:51 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 88B7C2A9A4; Sat, 15 May 2021 17:21:26 -0400 (EDT) Received: from mail-oo1-xc2b.google.com (mail-oo1-xc2b.google.com [IPv6:2607:f8b0:4864:20::c2b]) by mail.notmuchmail.org (Postfix) with ESMTPS id AB0D529050 for ; Sat, 15 May 2021 17:21:17 -0400 (EDT) Received: by mail-oo1-xc2b.google.com with SMTP id e27-20020a056820061bb029020da48eed5cso649611oow.10 for ; Sat, 15 May 2021 14:21:17 -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=KFbsYosfoXrFRFHENwOxTH9jM98VKtKNeQYnhourHxM=; b=PZqlBJf1LUJpKTfqC9q8LKHzVTbqkJft53ewHIFnf2c9hgXvlu0ISu0tN9RxDDDd5A PwYiRZbEpbwYlYUwaxY5hjhsi82n/JbHaSnWKPAAvYgN3LFQoFaX8EpOwBbkd38MkaBr 7Zf4DXodUDtRsvLnh74gsrn5Dc0hgNdQuFlADKO2pxzfr52PRG9vkfZcWnfthT/Dsahm UbwIincd48L3+uQ84lDBBy+PZmD1mnePMv7Q9dkhb2wvA1n9XHiTR2N1rpsr+zyxY+Is 0knw1nBNgVMIkxVsCS07tKmkrwI+2YoxR68cPLpEzrwn4RpAXU4BjbaxmML+IP9bto7/ 8ddQ== 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=KFbsYosfoXrFRFHENwOxTH9jM98VKtKNeQYnhourHxM=; b=aGodzpbH/rw0j1poo6Im1M3MBEHyXD0h4ogMCH/rFYjhzb+QuovKfWuyyCje9iRRGV tJEJpYJw1/bERN9k0f4GZ8cchurGQM7IRPrxkTdUg0TO+NOoadQmmB5PSbKwP5XvfC4C NidTUmZ34njeLzHkaBXcBA2hNEEDYhi7JfjxUgwmj7m8g3g20DOd2NHyw7UqHKMR+R0p vj65sbiKBPRwwxB3urozfUjaXtcF5eyIP9qaUmfkRlvbzODa0AoyWrYgrvnOLrsJSuXE Hvk/0ELhRtWF7NoKE/YaGs8uHKD4t60hXXM0u/6X+6KuumoNNWYsa7CNlug2pnzT6rKB xRrg== X-Gm-Message-State: AOAM5330YWswsFsUD5a9OPffniWpOl/DJY1FSQaQ9isEbRK2EExoUhr0 uYFQcl0n7+sQXZIaaO9D334Aliv1kJWTqA== X-Google-Smtp-Source: ABdhPJzN59+OTuIEplIhYgKcZThwZxzFz4zECwHyykhEd7BmqhzQt9OcllimZnIvT0BNFFnpC5OQbw== X-Received: by 2002:a4a:b997:: with SMTP id e23mr41120131oop.13.1621113674748; Sat, 15 May 2021 14:21:14 -0700 (PDT) Received: from localhost (fixed-187-189-165-231.totalplay.net. [187.189.165.231]) by smtp.gmail.com with ESMTPSA id e7sm2227770oos.15.2021.05.15.14.21.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 May 2021 14:21:14 -0700 (PDT) From: Felipe Contreras To: notmuch@notmuchmail.org Subject: [PATCH v3 6/7] ruby: add all data types Date: Sat, 15 May 2021 16:21:02 -0500 Message-Id: <20210515212103.1001295-7-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: 3UQ3ERKLS4LCL5DFPWG5TPA4EIKFC2OJ X-Message-ID-Hash: 3UQ3ERKLS4LCL5DFPWG5TPA4EIKFC2OJ 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=1621113711; 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=Md1SBe99KltNDnNB/aK2scKrF4bmWxhBQmHKoypantQ=; b=KKjDhXhdM3vz1I0BfQqNq0RFlKlGo55wO6g1Y9GQ8aVTA60hkpzAba7eo007/3NME6GTOx NlGEeXLTZ7YwI45ORl9g1OaNZAIOXxl6txefDfpoI7Xvz3zRls5VyiG1iZ1wUcgebZQuap hPTJuqfhsW3fl1C9StSPLkiEU5f4uwbhAK5H3kZqjPM32n+viqrlfnOzL7WXC1F2Q3yxM+ P8oBMObzv4izJImejr/jCO/RKAeSaUQz6+UcgNZ88msmrNMFmeo/vvhA8wcQ+ki9Q1QsU5 qM7WZZrscEQ3+zzuSVUD/diB+Z+V8l1z1OlJFnY7QX1A377L2FJkBndfZF4aDA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1621113711; a=rsa-sha256; cv=none; b=NnUkP0dn9sICjZEtiYBrNqMWFLkthBIK91vggXY7chd5Dz1LOkCxdbT2cbk2JCYhQ+wEhp ahX6AX0Zc9Hjc9agGrbB5iVSYP9fx+N28PB9VxJl0Rb1bzkfaZJmoSsD6XycynhTymuap0 TIUaFtYP0xkAiqztXYa8ofg4aQL9EY1HhO2sQ/WvleivvuFbjlY8joKo8gsDUv2Dhap4wL 13cy4SFKwa+4cFY3QUSPmKyAbSyfWWA1d5I4gMKTuPfURBfbzF8iL19G+1/bfl1+Gtc9Kj yAMfu4fMzsmbC51q3j1lmzEhs7rBP5GlOO7oBUGrJexIo34Kl1WqV8VkDrQsiw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20161025 header.b=PZqlBJf1; 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=PZqlBJf1; 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: 386E0B704 X-Spam-Score: -0.94 X-Migadu-Scanner: scn0.migadu.com X-TUID: ciMEVTyaWStM Signed-off-by: Felipe Contreras --- bindings/ruby/database.c | 16 ++++++++-------- bindings/ruby/defs.h | 37 +++++++++++++++++++++++-------------- bindings/ruby/directory.c | 4 ++-- bindings/ruby/init.c | 16 ++++++++++++++++ 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 +- 9 files changed, 60 insertions(+), 35 deletions(-) diff --git a/bindings/ruby/database.c b/bindings/ruby/database.c index bb4273e6..4ecc8f78 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_Notmuch_Object (klass, NULL); + return Data_Wrap_Notmuch_Object (klass, ¬much_rb_database_type, NULL); } /* @@ -74,7 +74,7 @@ notmuch_rb_database_initialize (int argc, VALUE *argv, VALUE self) mode = NOTMUCH_DATABASE_MODE_READ_ONLY; } - rb_check_typeddata (self, ¬much_rb_object_type); + rb_check_typeddata (self, ¬much_rb_database_type); if (create) ret = notmuch_database_create (path, &database); else @@ -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_Notmuch_Object (notmuch_rb_cDirectory, dir); + return Data_Wrap_Notmuch_Object (notmuch_rb_cDirectory, ¬much_rb_directory_type, 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_Notmuch_Object (notmuch_rb_cMessage, message), + return rb_assoc_new (Data_Wrap_Notmuch_Object (notmuch_rb_cMessage, ¬much_rb_message_type, 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_Notmuch_Object (notmuch_rb_cMessage, message); + return Data_Wrap_Notmuch_Object (notmuch_rb_cMessage, ¬much_rb_message_type, 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_Notmuch_Object (notmuch_rb_cMessage, message); + return Data_Wrap_Notmuch_Object (notmuch_rb_cMessage, ¬much_rb_message_type, 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_Notmuch_Object (notmuch_rb_cTags, tags); + return Data_Wrap_Notmuch_Object (notmuch_rb_cTags, ¬much_rb_tags_type, 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_Notmuch_Object (notmuch_rb_cQuery, query); + return Data_Wrap_Notmuch_Object (notmuch_rb_cQuery, ¬much_rb_query_type, query); } diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h index 6dbaa85d..fa7b9515 100644 --- a/bindings/ruby/defs.h +++ b/bindings/ruby/defs.h @@ -56,45 +56,54 @@ extern ID ID_db_mode; #endif /* !defined (RSTRING_PTR) */ extern const rb_data_type_t notmuch_rb_object_type; - -#define Data_Get_Notmuch_Object(obj, ptr) \ +extern const rb_data_type_t notmuch_rb_database_type; +extern const rb_data_type_t notmuch_rb_directory_type; +extern const rb_data_type_t notmuch_rb_filenames_type; +extern const rb_data_type_t notmuch_rb_query_type; +extern const rb_data_type_t notmuch_rb_threads_type; +extern const rb_data_type_t notmuch_rb_thread_type; +extern const rb_data_type_t notmuch_rb_messages_type; +extern const rb_data_type_t notmuch_rb_message_type; +extern const rb_data_type_t notmuch_rb_tags_type; + +#define Data_Get_Notmuch_Object(obj, type, ptr) \ do { \ - (ptr) = rb_check_typeddata ((obj), ¬much_rb_object_type); \ + (ptr) = rb_check_typeddata ((obj), (type)); \ if (RB_UNLIKELY (!(ptr))) { \ VALUE cname = rb_class_name (CLASS_OF ((obj))); \ rb_raise (rb_eRuntimeError, "%"PRIsVALUE" object destroyed", cname); \ } \ } while (0) -#define Data_Wrap_Notmuch_Object(klass, ptr) \ - TypedData_Wrap_Struct ((klass), ¬much_rb_object_type, (ptr)) +#define Data_Wrap_Notmuch_Object(klass, type, ptr) \ + TypedData_Wrap_Struct ((klass), (type), (ptr)) #define Data_Get_Notmuch_Database(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), (ptr)) + Data_Get_Notmuch_Object ((obj), ¬much_rb_database_type, (ptr)) #define Data_Get_Notmuch_Directory(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), (ptr)) + Data_Get_Notmuch_Object ((obj), ¬much_rb_directory_type, (ptr)) #define Data_Get_Notmuch_FileNames(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), (ptr)) + Data_Get_Notmuch_Object ((obj), ¬much_rb_filenames_type, (ptr)) #define Data_Get_Notmuch_Query(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), (ptr)) + Data_Get_Notmuch_Object ((obj), ¬much_rb_query_type, (ptr)) #define Data_Get_Notmuch_Threads(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), (ptr)) + Data_Get_Notmuch_Object ((obj), ¬much_rb_threads_type, (ptr)) #define Data_Get_Notmuch_Messages(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), (ptr)) + Data_Get_Notmuch_Object ((obj), ¬much_rb_messages_type, (ptr)) #define Data_Get_Notmuch_Thread(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), (ptr)) + Data_Get_Notmuch_Object ((obj), ¬much_rb_thread_type, (ptr)) #define Data_Get_Notmuch_Message(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), (ptr)) + Data_Get_Notmuch_Object ((obj), ¬much_rb_message_type, (ptr)) #define Data_Get_Notmuch_Tags(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), (ptr)) + Data_Get_Notmuch_Object ((obj), ¬much_rb_tags_type, (ptr)) /* status.c */ void diff --git a/bindings/ruby/directory.c b/bindings/ruby/directory.c index 36ef3984..17d60d1d 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_Notmuch_Object (notmuch_rb_cFileNames, fnames); + return Data_Wrap_Notmuch_Object (notmuch_rb_cFileNames, ¬much_rb_filenames_type, fnames); } /* @@ -111,5 +111,5 @@ notmuch_rb_directory_get_child_directories (VALUE self) fnames = notmuch_directory_get_child_directories (dir); - return Data_Wrap_Notmuch_Object (notmuch_rb_cFileNames, fnames); + return Data_Wrap_Notmuch_Object (notmuch_rb_cFileNames, ¬much_rb_filenames_type, fnames); } diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c index f3b2e5b1..a9f863eb 100644 --- a/bindings/ruby/init.c +++ b/bindings/ruby/init.c @@ -50,6 +50,22 @@ const rb_data_type_t notmuch_rb_object_type = { .wrap_struct_name = "notmuch_object", }; +#define define_type(id) \ + const rb_data_type_t notmuch_rb_ ## id ## _type = { \ + .wrap_struct_name = "notmuch_" #id, \ + .parent = ¬much_rb_object_type, \ + } + +define_type (database); +define_type (directory); +define_type (filenames); +define_type (query); +define_type (threads); +define_type (thread); +define_type (messages); +define_type (message); +define_type (tags); + /* * Document-module: Notmuch * diff --git a/bindings/ruby/message.c b/bindings/ruby/message.c index 1990bb97..b3aed604 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_Notmuch_Object (notmuch_rb_cMessages, messages); + return Data_Wrap_Notmuch_Object (notmuch_rb_cMessages, ¬much_rb_messages_type, messages); } /* @@ -125,7 +125,7 @@ notmuch_rb_message_get_filenames (VALUE self) fnames = notmuch_message_get_filenames (message); - return Data_Wrap_Notmuch_Object (notmuch_rb_cFileNames, fnames); + return Data_Wrap_Notmuch_Object (notmuch_rb_cFileNames, ¬much_rb_filenames_type, 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_Notmuch_Object (notmuch_rb_cTags, tags); + return Data_Wrap_Notmuch_Object (notmuch_rb_cTags, ¬much_rb_tags_type, tags); } /* diff --git a/bindings/ruby/messages.c b/bindings/ruby/messages.c index 3d1669ee..e04f3af1 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_Notmuch_Object (notmuch_rb_cMessage, message)); + rb_yield (Data_Wrap_Notmuch_Object (notmuch_rb_cMessage, ¬much_rb_message_type, 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_Notmuch_Object (notmuch_rb_cTags, tags); + return Data_Wrap_Notmuch_Object (notmuch_rb_cTags, ¬much_rb_tags_type, tags); } diff --git a/bindings/ruby/query.c b/bindings/ruby/query.c index b0fb4ea7..79727d6a 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_Notmuch_Object (notmuch_rb_cThreads, threads); + return Data_Wrap_Notmuch_Object (notmuch_rb_cThreads, ¬much_rb_threads_type, threads); } /* @@ -163,7 +163,7 @@ notmuch_rb_query_search_messages (VALUE self) if (status) notmuch_rb_status_raise (status); - return Data_Wrap_Notmuch_Object (notmuch_rb_cMessages, messages); + return Data_Wrap_Notmuch_Object (notmuch_rb_cMessages, ¬much_rb_messages_type, messages); } /* diff --git a/bindings/ruby/thread.c b/bindings/ruby/thread.c index e09be147..f6bf7849 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_Notmuch_Object (notmuch_rb_cMessages, messages); + return Data_Wrap_Notmuch_Object (notmuch_rb_cMessages, ¬much_rb_messages_type, 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_Notmuch_Object (notmuch_rb_cMessages, messages); + return Data_Wrap_Notmuch_Object (notmuch_rb_cMessages, ¬much_rb_messages_type, 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_Notmuch_Object (notmuch_rb_cTags, tags); + return Data_Wrap_Notmuch_Object (notmuch_rb_cTags, ¬much_rb_tags_type, tags); } diff --git a/bindings/ruby/threads.c b/bindings/ruby/threads.c index 19e09a7e..d809b571 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_Notmuch_Object (notmuch_rb_cThread, thread)); + rb_yield (Data_Wrap_Notmuch_Object (notmuch_rb_cThread, ¬much_rb_thread_type, thread)); } return self; -- 2.31.1