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);
}
/*
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
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;
}
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);
}
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;
}
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;
}
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);
}
/*
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);
}
#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
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);
}
/*
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);
}
.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
*
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);
}
/*
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);
}
/*
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);
}
/*
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;
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);
}
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);
}
/*
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);
}
/*
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);
}
/*
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);
}
/*
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);
}
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;