ext/looksee/looksee.c in looksee-0.0.2 vs ext/looksee/looksee.c in looksee-0.1.0
- old
+ new
@@ -113,14 +113,32 @@
*/
VALUE Looksee_internal_private_instance_methods(VALUE self, VALUE klass) {
return internal_instance_methods(klass, NOEX_PRIVATE);
}
+static int add_method_if_undefined(ID method_name, NODE *body, VALUE *names) {
+ /* Module#undef_method sets body->nd_body to NULL. */
+ if (body && !body->nd_body)
+ rb_ary_push(*names, ID2SYM(method_name));
+ return ST_CONTINUE;
+}
+
+/*
+ * Return the list of undefined instance methods (as Symbols) of the
+ * given internal class.
+ */
+VALUE Looksee_internal_undefined_instance_methods(VALUE self, VALUE klass) {
+ VALUE names = rb_ary_new();
+ st_foreach(RCLASS_M_TBL(klass), add_method_if_undefined, (st_data_t)&names);
+ return names;
+}
+
void Init_looksee(void) {
VALUE mLooksee = rb_define_module("Looksee");
rb_define_singleton_method(mLooksee, "internal_superclass", Looksee_internal_superclass, 1);
rb_define_singleton_method(mLooksee, "internal_class", Looksee_internal_class, 1);
rb_define_singleton_method(mLooksee, "internal_class_to_module", Looksee_internal_class_to_module, 1);
rb_define_singleton_method(mLooksee, "internal_public_instance_methods", Looksee_internal_public_instance_methods, 1);
rb_define_singleton_method(mLooksee, "internal_protected_instance_methods", Looksee_internal_protected_instance_methods, 1);
rb_define_singleton_method(mLooksee, "internal_private_instance_methods", Looksee_internal_private_instance_methods, 1);
+ rb_define_singleton_method(mLooksee, "internal_undefined_instance_methods", Looksee_internal_undefined_instance_methods, 1);
}