[前][次][番号順一覧][スレッド一覧]

ruby-changes:44409

From: nobu <ko1@a...>
Date: Mon, 24 Oct 2016 10:50:00 +0900 (JST)
Subject: [ruby-changes:44409] nobu:r56482 (trunk): class.c: rb_undef_methods_from

nobu	2016-10-24 10:49:52 +0900 (Mon, 24 Oct 2016)

  New Revision: 56482

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56482

  Log:
    class.c: rb_undef_methods_from
    
    * class.c (rb_undef_methods_from): undefine methods defined in
      super from klass.

  Modified files:
    trunk/ChangeLog
    trunk/class.c
    trunk/internal.h
Index: class.c
===================================================================
--- class.c	(revision 56481)
+++ class.c	(revision 56482)
@@ -1528,6 +1528,23 @@ rb_undef_method(VALUE klass, const char https://github.com/ruby/ruby/blob/trunk/class.c#L1528
     rb_add_method(klass, rb_intern(name), VM_METHOD_TYPE_UNDEF, 0, METHOD_VISI_UNDEF);
 }
 
+static enum rb_id_table_iterator_result
+undef_method_i(ID name, VALUE value, void *data)
+{
+    VALUE klass = (VALUE)data;
+    rb_add_method(klass, name, VM_METHOD_TYPE_UNDEF, 0, METHOD_VISI_UNDEF);
+    return ID_TABLE_CONTINUE;
+}
+
+void
+rb_undef_methods_from(VALUE klass, VALUE super)
+{
+    struct rb_id_table *mtbl = RCLASS_M_TBL(super);
+    if (mtbl) {
+	rb_id_table_foreach(mtbl, undef_method_i, (void *)klass);
+    }
+}
+
 /*!
  * \}
  */
Index: internal.h
===================================================================
--- internal.h	(revision 56481)
+++ internal.h	(revision 56482)
@@ -931,6 +931,7 @@ VALUE rb_singleton_class_get(VALUE obj); https://github.com/ruby/ruby/blob/trunk/internal.h#L931
 void Init_class_hierarchy(void);
 
 int rb_class_has_methods(VALUE c);
+void rb_undef_methods_from(VALUE klass, VALUE super);
 
 /* compar.c */
 VALUE rb_invcmp(VALUE, VALUE);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 56481)
+++ ChangeLog	(revision 56482)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Oct 24 10:49:50 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* class.c (rb_undef_methods_from): undefine methods defined in
+	  super from klass.
+
 Mon Oct 24 10:19:44 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* complex.c (Init_Complex): undefine Complex#clamp, which does not

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]