X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=bindings%2Fruby%2Fdefs.h;h=12538a3a1eb5d24e5df2ba033ee2b82d88be7d80;hb=682479592b33b13a22143f4fe67678c066bf223a;hp=e95ea239b0cea8c222c71e72d6b225f75f371641;hpb=2e57ffb860f2ca986fcb60548e4907d6e8fa912a;p=notmuch diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h index e95ea239..12538a3a 100644 --- a/bindings/ruby/defs.h +++ b/bindings/ruby/defs.h @@ -55,40 +55,41 @@ extern ID ID_db_mode; # define RSTRING_PTR(v) (RSTRING((v))->ptr) #endif /* !defined (RSTRING_PTR) */ -#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)); \ +#define Data_Get_Notmuch_Object(obj, ptr) \ + do { \ + (ptr) = rb_data_object_get ((obj)); \ + if (RB_UNLIKELY (!(ptr))) { \ + VALUE cname = rb_class_name (CLASS_OF ((obj))); \ + rb_raise (rb_eRuntimeError, "%"PRIsVALUE" object destroyed", cname); \ + } \ } while (0) #define Data_Get_Notmuch_Database(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), notmuch_database_t, "database closed", (ptr)) + Data_Get_Notmuch_Object ((obj), (ptr)) #define Data_Get_Notmuch_Directory(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), notmuch_directory_t, "directory destroyed", (ptr)) + Data_Get_Notmuch_Object ((obj), (ptr)) #define Data_Get_Notmuch_FileNames(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), notmuch_filenames_t, "filenames destroyed", (ptr)) + Data_Get_Notmuch_Object ((obj), (ptr)) #define Data_Get_Notmuch_Query(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), notmuch_query_t, "query destroyed", (ptr)) + Data_Get_Notmuch_Object ((obj), (ptr)) #define Data_Get_Notmuch_Threads(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), notmuch_threads_t, "threads destroyed", (ptr)) + Data_Get_Notmuch_Object ((obj), (ptr)) #define Data_Get_Notmuch_Messages(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), notmuch_messages_t, "messages destroyed", (ptr)) + Data_Get_Notmuch_Object ((obj), (ptr)) #define Data_Get_Notmuch_Thread(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), notmuch_thread_t, "thread destroyed", (ptr)) + Data_Get_Notmuch_Object ((obj), (ptr)) #define Data_Get_Notmuch_Message(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), notmuch_message_t, "message destroyed", (ptr)) + Data_Get_Notmuch_Object ((obj), (ptr)) #define Data_Get_Notmuch_Tags(obj, ptr) \ - Data_Get_Notmuch_Object ((obj), notmuch_tags_t, "tags destroyed", (ptr)) + Data_Get_Notmuch_Object ((obj), (ptr)) /* status.c */ void