Raise RuntimeError instead.
Also revise Notmuch::Database a bit.
Add Notmuch::Database.open singleton method.
#include "defs.h"
+VALUE
+notmuch_rb_database_alloc(VALUE klass)
+{
+ return Data_Wrap_Struct(klass, NULL, NULL, NULL);
+}
+
/*
- * call-seq: Notmuch::Database.new(path, [{:create => false, :mode => notmuch::MODE_READ_ONLY}]) => DB
+ * call-seq: Notmuch::Database.new(path [, {:create => false, :mode => Notmuch::MODE_READ_ONLY}]) => DB
*
* Create or open a notmuch database using the given path.
+ *
* If :create is +true+, create the database instead of opening.
+ *
* The argument :mode specifies the open mode of the database.
*/
VALUE
-notmuch_rb_database_new(int argc, VALUE *argv, VALUE klass)
+notmuch_rb_database_initialize(int argc, VALUE *argv, VALUE self)
{
const char *path;
int create, mode;
- notmuch_database_t *db;
VALUE pathv, hashv;
VALUE modev;
mode = NOTMUCH_DATABASE_MODE_READ_ONLY;
}
- db = create ? notmuch_database_create(path) : notmuch_database_open(path, mode);
- if (!db)
+ Check_Type(self, T_DATA);
+ DATA_PTR(self) = create ? notmuch_database_create(path) : notmuch_database_open(path, mode);
+ if (!DATA_PTR(self))
rb_raise(notmuch_rb_eDatabaseError, "Failed to open database");
- return Data_Wrap_Struct(klass, NULL, NULL, db);
+ return self;
+}
+
+/*
+ * call-seq: Notmuch::Database.open(path [, ahash]) {|db| ...}
+ *
+ * Identical to new, except that when it is called with a block, it yields with
+ * the new instance and closes it, and returns the result which is returned from
+ * the block.
+ */
+VALUE
+notmuch_rb_database_open(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE obj;
+
+ obj = rb_class_new_instance(argc, argv, klass);
+ if (!rb_block_given_p())
+ return obj;
+
+ return rb_ensure(rb_yield, obj, notmuch_rb_database_close, obj);
}
/*
{
notmuch_database_t *db;
- Data_Get_Struct(self, notmuch_database_t, db);
+ Data_Get_Notmuch_Database(self, db);
notmuch_database_close(db);
+ DATA_PTR(self) = NULL;
return Qnil;
}
{
notmuch_database_t *db;
- Data_Get_Struct(self, notmuch_database_t, db);
+ Data_Get_Notmuch_Database(self, db);
return rb_str_new2(notmuch_database_get_path(db));
}
{
notmuch_database_t *db;
- Data_Get_Struct(self, notmuch_database_t, db);
+ Data_Get_Notmuch_Database(self, db);
return INT2FIX(notmuch_database_get_version(db));
}
{
notmuch_database_t *db;
- Data_Get_Struct(self, notmuch_database_t, db);
+ Data_Get_Notmuch_Database(self, db);
return notmuch_database_needs_upgrade(db) ? Qtrue : Qfalse;
}
notmuch_database_t *db;
VALUE block;
- Data_Get_Struct(self, notmuch_database_t, db);
+ Data_Get_Notmuch_Database(self, db);
if (rb_block_given_p()) {
pnotify = notmuch_rb_upgrade_notify;
notmuch_directory_t *dir;
notmuch_database_t *db;
- Data_Get_Struct(self, notmuch_database_t, db);
+ Data_Get_Notmuch_Database(self, db);
#if !defined(RSTRING_PTR)
#define RSTRING_PTR(v) (RSTRING((v))->ptr)
notmuch_message_t *message;
notmuch_database_t *db;
- Data_Get_Struct(self, notmuch_database_t, db);
+ Data_Get_Notmuch_Database(self, db);
#if !defined(RSTRING_PTR)
#define RSTRING_PTR(v) (RSTRING((v))->ptr)
notmuch_status_t ret;
notmuch_database_t *db;
- Data_Get_Struct(self, notmuch_database_t, db);
+ Data_Get_Notmuch_Database(self, db);
#if !defined(RSTRING_PTR)
#define RSTRING_PTR(v) (RSTRING((v))->ptr)
notmuch_query_t *query;
notmuch_database_t *db;
- Data_Get_Struct(self, notmuch_database_t, db);
+ Data_Get_Notmuch_Database(self, db);
#if !defined(RSTRING_PTR)
#define RSTRING_PTR(v) (RSTRING((v))->ptr)
query = notmuch_query_create(db, qstr);
if (!query)
- rb_raise(notmuch_rb_eMemoryError, "out of memory");
+ rb_raise(notmuch_rb_eMemoryError, "Out of memory");
return Data_Wrap_Struct(notmuch_rb_cQuery, NULL, NULL, query);
}
ID ID_db_create;
ID ID_db_mode;
+#define Data_Get_Notmuch_Database(obj, ptr) \
+ do { \
+ Check_Type(obj, T_DATA); \
+ if (DATA_PTR(obj) == NULL) \
+ rb_raise(rb_eRuntimeError, "database closed"); \
+ Data_Get_Struct(obj, notmuch_database_t, ptr); \
+ } while(0)
+
+#define Data_Get_Notmuch_Directory(obj, ptr) \
+ do { \
+ Check_Type(obj, T_DATA); \
+ if (DATA_PTR(obj) == NULL) \
+ rb_raise(rb_eRuntimeError, "directory destroyed"); \
+ Data_Get_Struct(obj, notmuch_directory_t, ptr); \
+ } while(0)
+
+#define Data_Get_Notmuch_FileNames(obj, ptr) \
+ do { \
+ Check_Type(obj, T_DATA); \
+ if (DATA_PTR(obj) == NULL) \
+ rb_raise(rb_eRuntimeError, "filenames destroyed"); \
+ Data_Get_Struct(obj, notmuch_filenames_t, ptr); \
+ } while(0)
+
+#define Data_Get_Notmuch_Query(obj, ptr) \
+ do { \
+ Check_Type(obj, T_DATA); \
+ if (DATA_PTR(obj) == NULL) \
+ rb_raise(rb_eRuntimeError, "query destroyed"); \
+ Data_Get_Struct(obj, notmuch_query_t, ptr); \
+ } while(0)
+
+#define Data_Get_Notmuch_Threads(obj, ptr) \
+ do { \
+ Check_Type(obj, T_DATA); \
+ if (DATA_PTR(obj) == NULL) \
+ rb_raise(rb_eRuntimeError, "threads destroyed"); \
+ Data_Get_Struct(obj, notmuch_threads_t, ptr); \
+ } while(0)
+
+#define Data_Get_Notmuch_Messages(obj, ptr) \
+ do { \
+ Check_Type(obj, T_DATA); \
+ if (DATA_PTR(obj) == NULL) \
+ rb_raise(rb_eRuntimeError, "messages destroyed"); \
+ Data_Get_Struct(obj, notmuch_messages_t, ptr); \
+ } while(0)
+
+#define Data_Get_Notmuch_Thread(obj, ptr) \
+ do { \
+ Check_Type(obj, T_DATA); \
+ if (DATA_PTR(obj) == NULL) \
+ rb_raise(rb_eRuntimeError, "thread destroyed"); \
+ Data_Get_Struct(obj, notmuch_thread_t, ptr); \
+ } while(0)
+
+#define Data_Get_Notmuch_Message(obj, ptr) \
+ do { \
+ Check_Type(obj, T_DATA); \
+ if (DATA_PTR(obj) == NULL) \
+ rb_raise(rb_eRuntimeError, "message destroyed"); \
+ Data_Get_Struct(obj, notmuch_message_t, ptr); \
+ } while(0)
+
+#define Data_Get_Notmuch_Tags(obj, ptr) \
+ do { \
+ Check_Type(obj, T_DATA); \
+ if (DATA_PTR(obj) == NULL) \
+ rb_raise(rb_eRuntimeError, "tags destroyed"); \
+ Data_Get_Struct(obj, notmuch_tags_t, ptr); \
+ } while(0)
+
/* status.c */
void
notmuch_rb_status_raise(notmuch_status_t status);
/* database.c */
VALUE
-notmuch_rb_database_new(int argc, VALUE *argv, VALUE klass);
+notmuch_rb_database_alloc(VALUE klass);
+
+VALUE
+notmuch_rb_database_initialize(int argc, VALUE *argv, VALUE klass);
+
+VALUE
+notmuch_rb_database_open(int argc, VALUE *argv, VALUE klass);
VALUE
notmuch_rb_database_close(VALUE self);
Data_Get_Struct(self, notmuch_directory_t, dir);
notmuch_directory_destroy(dir);
+ DATA_PTR(self) = NULL;
return Qnil;
}
{
notmuch_directory_t *dir;
- Data_Get_Struct(self, notmuch_directory_t, dir);
+ Data_Get_Notmuch_Directory(self, dir);
return UINT2NUM(notmuch_directory_get_mtime(dir));
}
notmuch_status_t ret;
notmuch_directory_t *dir;
- Data_Get_Struct(self, notmuch_directory_t, dir);
+ Data_Get_Notmuch_Directory(self, dir);
if (!FIXNUM_P(mtimev))
rb_raise(rb_eTypeError, "First argument not a fixnum");
notmuch_directory_t *dir;
notmuch_filenames_t *fnames;
- Data_Get_Struct(self, notmuch_directory_t, dir);
+ Data_Get_Notmuch_Directory(self, dir);
fnames = notmuch_directory_get_child_files(dir);
notmuch_directory_t *dir;
notmuch_filenames_t *fnames;
- Data_Get_Struct(self, notmuch_directory_t, dir);
+ Data_Get_Notmuch_Directory(self, dir);
fnames = notmuch_directory_get_child_directories(dir);
{
notmuch_filenames_t *fnames;
- Data_Get_Struct(self, notmuch_filenames_t, fnames);
+ Data_Get_Notmuch_FileNames(self, fnames);
notmuch_filenames_destroy(fnames);
+ DATA_PTR(self) = NULL;
return Qnil;
}
{
notmuch_filenames_t *fnames;
- Data_Get_Struct(self, notmuch_filenames_t, fnames);
- if (!fnames)
- return self;
+ Data_Get_Notmuch_FileNames(self, fnames);
for (; notmuch_filenames_valid(fnames); notmuch_filenames_move_to_next(fnames))
rb_yield(rb_str_new2(notmuch_filenames_get(fnames)));
notmuch_rb_eUnbalancedFreezeThawError = rb_define_class_under(mod, "UnbalancedFreezeThawError",
notmuch_rb_eBaseError);
- notmuch_rb_cDatabase = rb_define_class_under(mod, "Database", rb_cObject);
- rb_define_singleton_method(notmuch_rb_cDatabase, "new", notmuch_rb_database_new, -1);
+ notmuch_rb_cDatabase = rb_define_class_under(mod, "Database", rb_cData);
+ rb_define_alloc_func(notmuch_rb_cDatabase, notmuch_rb_database_alloc);
+ rb_define_singleton_method(notmuch_rb_cDatabase, "open", notmuch_rb_database_open, -1);
+ rb_define_method(notmuch_rb_cDatabase, "initialize", notmuch_rb_database_initialize, -1);
rb_define_method(notmuch_rb_cDatabase, "close", notmuch_rb_database_close, 0);
rb_define_method(notmuch_rb_cDatabase, "path", notmuch_rb_database_path, 0);
rb_define_method(notmuch_rb_cDatabase, "version", notmuch_rb_database_version, 0);
rb_define_method(notmuch_rb_cDatabase, "remove_message", notmuch_rb_database_remove_message, 1);
rb_define_method(notmuch_rb_cDatabase, "query", notmuch_rb_database_query_create, 1);
- notmuch_rb_cDirectory = rb_define_class_under(mod, "Directory", rb_cObject);
+ notmuch_rb_cDirectory = rb_define_class_under(mod, "Directory", rb_cData);
rb_undef_method(notmuch_rb_cDirectory, "initialize");
rb_define_method(notmuch_rb_cDirectory, "destroy", notmuch_rb_directory_destroy, 0);
rb_define_method(notmuch_rb_cDirectory, "mtime", notmuch_rb_directory_get_mtime, 0);
rb_define_method(notmuch_rb_cDirectory, "child_files", notmuch_rb_directory_get_child_files, 0);
rb_define_method(notmuch_rb_cDirectory, "child_directories", notmuch_rb_directory_get_child_directories, 0);
- notmuch_rb_cFileNames = rb_define_class_under(mod, "FileNames", rb_cObject);
+ notmuch_rb_cFileNames = rb_define_class_under(mod, "FileNames", rb_cData);
rb_undef_method(notmuch_rb_cFileNames, "initialize");
rb_define_method(notmuch_rb_cFileNames, "destroy", notmuch_rb_filenames_destroy, 0);
rb_define_method(notmuch_rb_cFileNames, "each", notmuch_rb_filenames_each, 0);
rb_include_module(notmuch_rb_cFileNames, rb_mEnumerable);
- notmuch_rb_cQuery = rb_define_class_under(mod, "Query", rb_cObject);
+ notmuch_rb_cQuery = rb_define_class_under(mod, "Query", rb_cData);
rb_undef_method(notmuch_rb_cQuery, "initialize");
rb_define_method(notmuch_rb_cQuery, "destroy", notmuch_rb_query_destroy, 0);
rb_define_method(notmuch_rb_cQuery, "sort=", notmuch_rb_query_set_sort, 1);
rb_define_method(notmuch_rb_cQuery, "search_threads", notmuch_rb_query_search_threads, 0);
rb_define_method(notmuch_rb_cQuery, "search_messages", notmuch_rb_query_search_messages, 0);
- notmuch_rb_cThreads = rb_define_class_under(mod, "Threads", rb_cObject);
+ notmuch_rb_cThreads = rb_define_class_under(mod, "Threads", rb_cData);
rb_undef_method(notmuch_rb_cThreads, "initialize");
rb_define_method(notmuch_rb_cThreads, "destroy", notmuch_rb_threads_destroy, 0);
rb_define_method(notmuch_rb_cThreads, "each", notmuch_rb_threads_each, 0);
rb_include_module(notmuch_rb_cThreads, rb_mEnumerable);
- notmuch_rb_cMessages = rb_define_class_under(mod, "Messages", rb_cObject);
+ notmuch_rb_cMessages = rb_define_class_under(mod, "Messages", rb_cData);
rb_undef_method(notmuch_rb_cMessages, "initialize");
rb_define_method(notmuch_rb_cMessages, "destroy", notmuch_rb_messages_destroy, 0);
rb_define_method(notmuch_rb_cMessages, "each", notmuch_rb_messages_each, 0);
rb_define_method(notmuch_rb_cMessages, "tags", notmuch_rb_messages_collect_tags, 0);
rb_include_module(notmuch_rb_cMessages, rb_mEnumerable);
- notmuch_rb_cThread = rb_define_class_under(mod, "Thread", rb_cObject);
+ notmuch_rb_cThread = rb_define_class_under(mod, "Thread", rb_cData);
rb_undef_method(notmuch_rb_cThread, "initialize");
rb_define_method(notmuch_rb_cThread, "destroy", notmuch_rb_thread_destroy, 0);
rb_define_method(notmuch_rb_cThread, "thread_id", notmuch_rb_thread_get_thread_id, 0);
rb_define_method(notmuch_rb_cThread, "newest_date", notmuch_rb_thread_get_newest_date, 0);
rb_define_method(notmuch_rb_cThread, "tags", notmuch_rb_thread_get_tags, 0);
- notmuch_rb_cMessage = rb_define_class_under(mod, "Message", rb_cObject);
+ notmuch_rb_cMessage = rb_define_class_under(mod, "Message", rb_cData);
rb_undef_method(notmuch_rb_cMessage, "initialize");
rb_define_method(notmuch_rb_cMessage, "destroy", notmuch_rb_message_destroy, 0);
rb_define_method(notmuch_rb_cMessage, "message_id", notmuch_rb_message_get_message_id, 0);
rb_define_method(notmuch_rb_cMessage, "freeze", notmuch_rb_message_freeze, 0);
rb_define_method(notmuch_rb_cMessage, "thaw", notmuch_rb_message_thaw, 0);
- notmuch_rb_cTags = rb_define_class_under(mod, "Tags", rb_cObject);
+ notmuch_rb_cTags = rb_define_class_under(mod, "Tags", rb_cData);
rb_undef_method(notmuch_rb_cTags, "initialize");
rb_define_method(notmuch_rb_cTags, "destroy", notmuch_rb_tags_destroy, 0);
rb_define_method(notmuch_rb_cTags, "each", notmuch_rb_tags_each, 0);
{
notmuch_message_t *message;
- Data_Get_Struct(self, notmuch_message_t, message);
+ Data_Get_Notmuch_Message(self, message);
notmuch_message_destroy(message);
+ DATA_PTR(self) = NULL;
return Qnil;
}
const char *msgid;
notmuch_message_t *message;
- Data_Get_Struct(self, notmuch_message_t, message);
+ Data_Get_Notmuch_Message(self, message);
msgid = notmuch_message_get_message_id(message);
const char *tid;
notmuch_message_t *message;
- Data_Get_Struct(self, notmuch_message_t, message);
+ Data_Get_Notmuch_Message(self, message);
tid = notmuch_message_get_thread_id(message);
notmuch_messages_t *messages;
notmuch_message_t *message;
- Data_Get_Struct(self, notmuch_message_t, message);
+ Data_Get_Notmuch_Message(self, message);
messages = notmuch_message_get_replies(message);
const char *fname;
notmuch_message_t *message;
- Data_Get_Struct(self, notmuch_message_t, message);
+ Data_Get_Notmuch_Message(self, message);
fname = notmuch_message_get_filename(message);
{
notmuch_message_t *message;
- Data_Get_Struct(self, notmuch_message_t, message);
+ Data_Get_Notmuch_Message(self, message);
if (!FIXNUM_P(flagv))
rb_raise(rb_eTypeError, "Flag not a Fixnum");
{
notmuch_message_t *message;
- Data_Get_Struct(self, notmuch_message_t, message);
+ Data_Get_Notmuch_Message(self, message);
if (!FIXNUM_P(flagv))
rb_raise(rb_eTypeError, "Flag not a Fixnum");
{
notmuch_message_t *message;
- Data_Get_Struct(self, notmuch_message_t, message);
+ Data_Get_Notmuch_Message(self, message);
return UINT2NUM(notmuch_message_get_date(message));
}
const char *header, *value;
notmuch_message_t *message;
- Data_Get_Struct(self, notmuch_message_t, message);
+ Data_Get_Notmuch_Message(self, message);
#if !defined(RSTRING_PTR)
#define RSTRING_PTR(v) (RSTRING((v))->ptr)
notmuch_message_t *message;
notmuch_tags_t *tags;
- Data_Get_Struct(self, notmuch_message_t, message);
+ Data_Get_Notmuch_Message(self, message);
tags = notmuch_message_get_tags(message);
if (!tags)
notmuch_status_t ret;
notmuch_message_t *message;
- Data_Get_Struct(self, notmuch_message_t, message);
+ Data_Get_Notmuch_Message(self, message);
#if !defined(RSTRING_PTR)
#define RSTRING_PTR(v) (RSTRING((v))->ptr)
notmuch_status_t ret;
notmuch_message_t *message;
- Data_Get_Struct(self, notmuch_message_t, message);
+ Data_Get_Notmuch_Message(self, message);
#if !defined(RSTRING_PTR)
#define RSTRING_PTR(v) (RSTRING((v))->ptr)
notmuch_status_t ret;
notmuch_message_t *message;
- Data_Get_Struct(self, notmuch_message_t, message);
+ Data_Get_Notmuch_Message(self, message);
ret = notmuch_message_remove_all_tags(message);
notmuch_rb_status_raise(ret);
notmuch_status_t ret;
notmuch_message_t *message;
- Data_Get_Struct(self, notmuch_message_t, message);
+ Data_Get_Notmuch_Message(self, message);
ret = notmuch_message_freeze(message);
notmuch_rb_status_raise(ret);
notmuch_status_t ret;
notmuch_message_t *message;
- Data_Get_Struct(self, notmuch_message_t, message);
+ Data_Get_Notmuch_Message(self, message);
ret = notmuch_message_thaw(message);
notmuch_rb_status_raise(ret);
VALUE
notmuch_rb_messages_destroy(VALUE self)
{
- notmuch_messages_t *fnames;
+ notmuch_messages_t *messages;
- Data_Get_Struct(self, notmuch_messages_t, fnames);
+ Data_Get_Notmuch_Messages(self, messages);
- notmuch_messages_destroy(fnames);
+ notmuch_messages_destroy(messages);
+ DATA_PTR(self) = NULL;
return Qnil;
}
notmuch_message_t *message;
notmuch_messages_t *messages;
- Data_Get_Struct(self, notmuch_messages_t, messages);
- if (!messages)
- return self;
+ Data_Get_Notmuch_Messages(self, messages);
for (; notmuch_messages_valid(messages); notmuch_messages_move_to_next(messages)) {
message = notmuch_messages_get(messages);
notmuch_tags_t *tags;
notmuch_messages_t *messages;
- Data_Get_Struct(self, notmuch_messages_t, messages);
+ Data_Get_Notmuch_Messages(self, messages);
tags = notmuch_messages_collect_tags(messages);
if (!tags)
{
notmuch_query_t *query;
- Data_Get_Struct(self, notmuch_query_t, query);
+ Data_Get_Notmuch_Query(self, query);
notmuch_query_destroy(query);
+ DATA_PTR(self) = NULL;
return Qnil;
}
{
notmuch_query_t *query;
- Data_Get_Struct(self, notmuch_query_t, query);
+ Data_Get_Notmuch_Query(self, query);
if (!FIXNUM_P(sortv))
- rb_raise(rb_eTypeError, "Not a fixnum");
+ rb_raise(rb_eTypeError, "Not a Fixnum");
notmuch_query_set_sort(query, FIX2UINT(sortv));
notmuch_query_t *query;
notmuch_threads_t *threads;
- Data_Get_Struct(self, notmuch_query_t, query);
+ Data_Get_Notmuch_Query(self, query);
threads = notmuch_query_search_threads(query);
if (!threads)
notmuch_query_t *query;
notmuch_messages_t *messages;
- Data_Get_Struct(self, notmuch_query_t, query);
+ Data_Get_Notmuch_Query(self, query);
messages = notmuch_query_search_messages(query);
if (!messages)
#include "defs.h"
/*
- * call-seq: tags.destroy => nil
+ * call-seq: TAGS.destroy => nil
*
* Destroys the tags, freeing all resources allocated for it.
*/
{
notmuch_tags_t *tags;
- Data_Get_Struct(self, notmuch_tags_t, tags);
+ Data_Get_Notmuch_Tags(self, tags);
notmuch_tags_destroy(tags);
+ DATA_PTR(self) = NULL;
return Qnil;
}
const char *tag;
notmuch_tags_t *tags;
- Data_Get_Struct(self, notmuch_tags_t, tags);
- if (!tags)
- return self;
+ Data_Get_Notmuch_Tags(self, tags);
for (; notmuch_tags_valid(tags); notmuch_tags_move_to_next(tags)) {
tag = notmuch_tags_get(tags);
{
notmuch_thread_t *thread;
- Data_Get_Struct(self, notmuch_thread_t, thread);
+ Data_Get_Notmuch_Thread(self, thread);
notmuch_thread_destroy(thread);
+ DATA_PTR(self) = NULL;
return Qnil;
}
const char *tid;
notmuch_thread_t *thread;
- Data_Get_Struct(self, notmuch_thread_t, thread);
+ Data_Get_Notmuch_Thread(self, thread);
tid = notmuch_thread_get_thread_id(thread);
{
notmuch_thread_t *thread;
- Data_Get_Struct(self, notmuch_thread_t, thread);
+ Data_Get_Notmuch_Thread(self, thread);
return INT2FIX(notmuch_thread_get_total_messages(thread));
}
notmuch_messages_t *messages;
notmuch_thread_t *thread;
- Data_Get_Struct(self, notmuch_thread_t, thread);
+ Data_Get_Notmuch_Thread(self, thread);
messages = notmuch_thread_get_toplevel_messages(thread);
if (!messages)
{
notmuch_thread_t *thread;
- Data_Get_Struct(self, notmuch_thread_t, thread);
+ Data_Get_Notmuch_Thread(self, thread);
return INT2FIX(notmuch_thread_get_matched_messages(thread));
}
const char *authors;
notmuch_thread_t *thread;
- Data_Get_Struct(self, notmuch_thread_t, thread);
+ Data_Get_Notmuch_Thread(self, thread);
authors = notmuch_thread_get_authors(thread);
const char *subject;
notmuch_thread_t *thread;
- Data_Get_Struct(self, notmuch_thread_t, thread);
+ Data_Get_Notmuch_Thread(self, thread);
subject = notmuch_thread_get_subject(thread);
{
notmuch_thread_t *thread;
- Data_Get_Struct(self, notmuch_thread_t, thread);
+ Data_Get_Notmuch_Thread(self, thread);
return UINT2NUM(notmuch_thread_get_oldest_date(thread));
}
{
notmuch_thread_t *thread;
- Data_Get_Struct(self, notmuch_thread_t, thread);
+ Data_Get_Notmuch_Thread(self, thread);
return UINT2NUM(notmuch_thread_get_newest_date(thread));
}
notmuch_thread_t *thread;
notmuch_tags_t *tags;
- Data_Get_Struct(self, notmuch_thread_t, thread);
+ Data_Get_Notmuch_Thread(self, thread);
tags = notmuch_thread_get_tags(thread);
if (!tags)
Data_Get_Struct(self, notmuch_threads_t, threads);
notmuch_threads_destroy(threads);
+ DATA_PTR(self) = NULL;
return Qnil;
}
-
/* call-seq: THREADS.each {|item| block } => THREADS
*
* Calls +block+ once for each thread in +self+, passing that element as a
notmuch_thread_t *thread;
notmuch_threads_t *threads;
- Data_Get_Struct(self, notmuch_threads_t, threads);
- if (!threads)
- return self;
+ Data_Get_Notmuch_Threads(self, threads);
for (; notmuch_threads_valid(threads); notmuch_threads_move_to_next(threads)) {
thread = notmuch_threads_get(threads);