X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=bindings%2Fruby%2Fdefs.h;h=fcf1ea3900ca97cf5ae9c872b6bd86b04f331a0d;hb=12c36a5e3f676d5108cede6ac09204fb62fa20b1;hp=e95ea239b0cea8c222c71e72d6b225f75f371641;hpb=2e57ffb860f2ca986fcb60548e4907d6e8fa912a;p=notmuch diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h index e95ea239..fcf1ea39 100644 --- a/bindings/ruby/defs.h +++ b/bindings/ruby/defs.h @@ -55,40 +55,44 @@ 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_Wrap_Notmuch_Object(klass, ptr) \ + Data_Wrap_Struct ((klass), NULL, NULL, (ptr)) + #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