[PATCH 1/3] ruby: add filenames helper

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

Date: Mon, 27 Mar 2023 15:59:40 -0600

To: notmuch@notmuchmail.org

Cc:

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/defs.h      | 3 +++
 bindings/ruby/directory.c | 4 ++--
 bindings/ruby/filenames.c | 6 ++++++
 bindings/ruby/message.c   | 2 +-
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h
index e2541e8f..216380d4 100644
--- a/bindings/ruby/defs.h
+++ b/bindings/ruby/defs.h
@@ -225,6 +225,9 @@ VALUE
 notmuch_rb_directory_get_child_directories (VALUE self);
 
 /* filenames.c */
+VALUE
+notmuch_rb_filenames_get (notmuch_filenames_t *fnames);
+
 VALUE
 notmuch_rb_filenames_destroy (VALUE self);
 
diff --git a/bindings/ruby/directory.c b/bindings/ruby/directory.c
index 910f0a99..f267d82f 100644
--- a/bindings/ruby/directory.c
+++ b/bindings/ruby/directory.c
@@ -87,7 +87,7 @@ notmuch_rb_directory_get_child_files (VALUE self)
 
     fnames = notmuch_directory_get_child_files (dir);
 
-    return Data_Wrap_Notmuch_Object (notmuch_rb_cFileNames, &notmuch_rb_filenames_type, fnames);
+    return notmuch_rb_filenames_get (fnames);
 }
 
 /*
@@ -106,5 +106,5 @@ notmuch_rb_directory_get_child_directories (VALUE self)
 
     fnames = notmuch_directory_get_child_directories (dir);
 
-    return Data_Wrap_Notmuch_Object (notmuch_rb_cFileNames, &notmuch_rb_filenames_type, fnames);
+    return notmuch_rb_filenames_get (fnames);
 }
diff --git a/bindings/ruby/filenames.c b/bindings/ruby/filenames.c
index 0dec1952..17873393 100644
--- a/bindings/ruby/filenames.c
+++ b/bindings/ruby/filenames.c
@@ -20,6 +20,12 @@
 
 #include "defs.h"
 
+VALUE
+notmuch_rb_filenames_get (notmuch_filenames_t *fnames)
+{
+    return Data_Wrap_Notmuch_Object (notmuch_rb_cFileNames, &notmuch_rb_filenames_type, fnames);
+}
+
 /*
  * call-seq: FILENAMES.destroy! => nil
  *
diff --git a/bindings/ruby/message.c b/bindings/ruby/message.c
index f45c95cc..0d83567c 100644
--- a/bindings/ruby/message.c
+++ b/bindings/ruby/message.c
@@ -120,7 +120,7 @@ notmuch_rb_message_get_filenames (VALUE self)
 
     fnames = notmuch_message_get_filenames (message);
 
-    return Data_Wrap_Notmuch_Object (notmuch_rb_cFileNames, &notmuch_rb_filenames_type, fnames);
+    return notmuch_rb_filenames_get (fnames);
 }
 
 /*
-- 
2.39.2.13.g1fb56cf030

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

Thread: