+#define CHECK_CLASS(val, klass) \
+ if (!rb_obj_is_kind_of ((val), (klass))) { \
+ rb_raise (rb_eTypeError, \
+ "wrong argument type %s (expected %s)", \
+ rb_obj_classname ((val)), \
+ rb_obj_classname ((klass))); \
+ return Qnil; \
+ }
+
+#define INSPECT(obj, type) \
+ char buf[128]; \
+\
+ GET_OBJ (obj, type, o); \
+\
+ snprintf (buf, sizeof (buf), \
+ "#<%s:%p ptr=%p>", rb_obj_classname ((obj)), \
+ (void *) obj, *o); \
+\
+ return rb_str_new2 (buf);
+