[PATCH 1/3] ruby: add tags helper

Subject: [PATCH 1/3] ruby: add tags helper

Date: Wed, 22 Mar 2023 17:43:44 -0600

To: notmuch@notmuchmail.org

Cc: arcnmx

From: Felipe Contreras


Right now it doesn't do much, but it will help for further
reorganization.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 bindings/ruby/database.c | 2 +-
 bindings/ruby/defs.h     | 3 +++
 bindings/ruby/message.c  | 2 +-
 bindings/ruby/messages.c | 2 +-
 bindings/ruby/tags.c     | 6 ++++++
 bindings/ruby/thread.c   | 2 +-
 6 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/bindings/ruby/database.c b/bindings/ruby/database.c
index 9c3dbd96..9cac6005 100644
--- a/bindings/ruby/database.c
+++ b/bindings/ruby/database.c
@@ -408,7 +408,7 @@ notmuch_rb_database_get_all_tags (VALUE self)
 
 	rb_raise (notmuch_rb_eBaseError, "%s", msg);
     }
-    return Data_Wrap_Notmuch_Object (notmuch_rb_cTags, &notmuch_rb_tags_type, tags);
+    return notmuch_rb_tags_get (tags);
 }
 
 /*
diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h
index e2541e8f..9454658b 100644
--- a/bindings/ruby/defs.h
+++ b/bindings/ruby/defs.h
@@ -369,6 +369,9 @@ VALUE
 notmuch_rb_message_thaw (VALUE self);
 
 /* tags.c */
+VALUE
+notmuch_rb_tags_get (notmuch_tags_t *tags);
+
 VALUE
 notmuch_rb_tags_destroy (VALUE self);
 
diff --git a/bindings/ruby/message.c b/bindings/ruby/message.c
index f45c95cc..81085f75 100644
--- a/bindings/ruby/message.c
+++ b/bindings/ruby/message.c
@@ -221,7 +221,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, &notmuch_rb_tags_type, tags);
+    return notmuch_rb_tags_get (tags);
 }
 
 /*
diff --git a/bindings/ruby/messages.c b/bindings/ruby/messages.c
index ca5b10d0..6369d052 100644
--- a/bindings/ruby/messages.c
+++ b/bindings/ruby/messages.c
@@ -71,5 +71,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, &notmuch_rb_tags_type, tags);
+    return notmuch_rb_tags_get (tags);
 }
diff --git a/bindings/ruby/tags.c b/bindings/ruby/tags.c
index 2af85e36..cc6ea59e 100644
--- a/bindings/ruby/tags.c
+++ b/bindings/ruby/tags.c
@@ -20,6 +20,12 @@
 
 #include "defs.h"
 
+VALUE
+notmuch_rb_tags_get (notmuch_tags_t *tags)
+{
+    return Data_Wrap_Notmuch_Object (notmuch_rb_cTags, &notmuch_rb_tags_type, tags);
+}
+
 /*
  * call-seq: TAGS.destroy! => nil
  *
diff --git a/bindings/ruby/thread.c b/bindings/ruby/thread.c
index 7cb2a3dc..b20ed893 100644
--- a/bindings/ruby/thread.c
+++ b/bindings/ruby/thread.c
@@ -204,5 +204,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, &notmuch_rb_tags_type, tags);
+    return notmuch_rb_tags_get (tags);
 }
-- 
2.39.2.13.g1fb56cf030

_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: