-#define Data_Get_Notmuch_Object(obj, type, message, ptr) \
- do { \
- Check_Type ((obj), T_DATA); \
- if (DATA_PTR ((obj)) == NULL) \
- rb_raise (rb_eRuntimeError, (message)); \
- Data_Get_Struct ((obj), type, (ptr)); \
+extern const rb_data_type_t notmuch_rb_object_type;
+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), (type)); \
+ if (RB_UNLIKELY (!(ptr))) { \
+ VALUE cname = rb_class_name (CLASS_OF ((obj))); \
+ rb_raise (rb_eRuntimeError, "%"PRIsVALUE" object destroyed", cname); \
+ } \