summaryrefslogtreecommitdiffstats
path: root/class.c
diff options
context:
space:
mode:
Diffstat (limited to 'class.c')
-rw-r--r--class.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/class.c b/class.c
index 2aac32fc0..c7aa72344 100644
--- a/class.c
+++ b/class.c
@@ -344,7 +344,7 @@ include_class_new(VALUE module, VALUE super)
void
rb_include_module(VALUE klass, VALUE module)
{
- VALUE p, c;
+ VALUE c;
int changed = 0;
rb_frozen_class_p(klass);
@@ -362,30 +362,11 @@ rb_include_module(VALUE klass, VALUE module)
OBJ_INFECT(klass, module);
c = klass;
while (module) {
- int superclass_seen = Qfalse;
-
if (RCLASS(klass)->m_tbl == RCLASS(module)->m_tbl)
rb_raise(rb_eArgError, "cyclic include detected");
- /* ignore if the module included already in superclasses */
- for (p = RCLASS(klass)->super; p; p = RCLASS(p)->super) {
- switch (BUILTIN_TYPE(p)) {
- case T_ICLASS:
- if (RCLASS(p)->m_tbl == RCLASS(module)->m_tbl) {
- if (!superclass_seen) {
- c = p; /* move insertion point */
- }
- goto skip;
- }
- break;
- case T_CLASS:
- superclass_seen = Qtrue;
- break;
- }
- }
RCLASS(c)->super = include_class_new(module, RCLASS(c)->super);
c = RCLASS(c)->super;
changed = 1;
- skip:
module = RCLASS(module)->super;
}
if (changed) rb_clear_cache();
@@ -500,6 +481,7 @@ ins_methods_push(ID name, long type, VALUE ary, long visi)
case NOEX_PRIVATE:
case NOEX_PROTECTED:
case NOEX_PUBLIC:
+ case NOEX_LOCAL:
visi = (type == visi);
break;
default:
@@ -537,6 +519,12 @@ ins_methods_pub_i(ID name, long type, VALUE ary)
}
static int
+ins_methods_local_i(ID name, long type, VALUE ary)
+{
+ return ins_methods_push(name, type, ary, NOEX_LOCAL);
+}
+
+static int
method_entry(ID key, NODE *body, st_table *list)
{
long type;
@@ -668,6 +656,19 @@ rb_class_public_instance_methods(int argc, VALUE *argv, VALUE mod)
/*
* call-seq:
+ * mod.local_methods => array
+ *
+ * Returns a list of the local methods defined in <i>mod</i>.
+ */
+
+VALUE
+rb_class_local_methods(VALUE mod)
+{
+ return class_instance_method_list(0, 0, mod, ins_methods_local_i);
+}
+
+/*
+ * call-seq:
* obj.singleton_methods(all=true) => array
*
* Returns an array of the names of singleton methods for <i>obj</i>.