From ae1336dea5cc6a221699fff260d8b44cee677f77 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Wed, 22 Mar 2023 17:43:44 -0600 Subject: [PATCH] ruby: add tags helper Right now it doesn't do much, but it will help for further reorganization. Signed-off-by: Felipe Contreras --- 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 b6de1254..e6387f59 100644 --- a/bindings/ruby/database.c +++ b/bindings/ruby/database.c @@ -412,7 +412,7 @@ notmuch_rb_database_get_all_tags (VALUE self) rb_raise (notmuch_rb_eBaseError, "%s", msg); } - return Data_Wrap_Notmuch_Object (notmuch_rb_cTags, ¬much_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, ¬much_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, ¬much_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, ¬much_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, ¬much_rb_tags_type, tags); + return notmuch_rb_tags_get (tags); } -- 2.43.0