X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=bindings%2Fruby%2Fdefs.h;h=6dbaa85dcfbcd0fd5ec03146d11d176483245cfa;hb=fba9774a81e90a179ccfa810c47a501eaf266e2b;hp=12538a3a1eb5d24e5df2ba033ee2b82d88be7d80;hpb=682479592b33b13a22143f4fe67678c066bf223a;p=notmuch diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h index 12538a3a..6dbaa85d 100644 --- a/bindings/ruby/defs.h +++ b/bindings/ruby/defs.h @@ -55,15 +55,20 @@ extern ID ID_db_mode; # define RSTRING_PTR(v) (RSTRING((v))->ptr) #endif /* !defined (RSTRING_PTR) */ +extern const rb_data_type_t notmuch_rb_object_type; + #define Data_Get_Notmuch_Object(obj, ptr) \ do { \ - (ptr) = rb_data_object_get ((obj)); \ + (ptr) = rb_check_typeddata ((obj), ¬much_rb_object_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_Get_Notmuch_Database(obj, ptr) \ Data_Get_Notmuch_Object ((obj), (ptr))